Welcome to mirkes.de's Tiny Hexer

Help index

Welcome to mirkes.de's Tiny Hexer! This help file contains information about Tiny Hexer, a free binary file editor by mirkes.de.
  • Introduction
  • Frequently asked questions
  • The main window
  • The editor window
  • Tiny Hexer Script
  • Tool windows:

    • Structure viewer
    • Value editor
    • Position list
    • Calculator
    • Status window
    • Editor finder
mirkes.de's Tiny Hexer, Copyright © Markus Stephany. All rights reserved.


Introduction to Tiny Hexer

Here you can find some basic information about Tiny Hexer.
  • Features
  • License
  • Credits
  • About the author
  • Version history

Features

  • Search and replace of text or hex bytes (also with wildcard byte and regular expressions)
  • File statistics and graphical data representation
  • Editable file size up to 2 GB (depends on available virtual memory, in "disk image" mode also larger files can be edited sector/blockwise)
  • Native 32 Bit Windows application, MDI
  • Ascii, Ansi, EBCDIC (Codepage 38), Macintosh™ and custom character conversion
  • Unicode (UCS-2) support (character display, search and replace)
  • Scripting engine (Tiny Hexer Script language) including macro recording and calling of stdcall functions in dynamic link libraries
  • Plugin interface to enhance Tiny Hexer and Tiny Hexer Script functionality with your own Delphi plugins (SDK is currently not available, sorry...)
  • Insert and delete half bytes
  • Insert, overwrite and readonly modes
  • Common bookmarks and keyboard bookmarks per file
  • Cutting and pasting of binary data (also NULL-bytes)
  • Automatic backups of modified files
  • Configurable keyboard, shortcuts and toolbar
  • Value editor to modify bytes, words, IEEE and IBM floating point numbers, single bits...
  • Structure viewer to better understand file structures (with sample structure scripts for .bmp, .exe, .lnk and .zip files and NTFS, FAT16 and FAT32 boot structures)
  • Multiple undo, single redo capabilities
  • OLE drag and drop support
  • Disk editing (Windows NT/2000/XP only)
  • Support for Alternate Data Streams on NTFS
  • Modification of virtual memory in other processes
  • Configurable editor appearance
  • Save and reload sets of options
  • Scriptable file import and export (with sample import scripts for hex text, Intel hex and Motorola S-record and sample export scripts/plugins for c-source file, pascal-source file, hex text, Intel hex, Motorola S-record, RTF, Plain Text, Unicode text and HTML)
  • Absolutely free of charge!
  • and more...

License

mirkes.de's Tiny Hexer ("the software") license agreement:

by unpacking or running any application from this package, you agree to be
bound by and are becoming a party to this agreement. if you do not agree to
all of the terms of this license agreement, you must destroy the package.

markus stephany ("the author") grants you a non-exclusive license to use the
software free of charge.

this agreement shall be interpreted in accordance with the laws of the
federal republic of germany without application of that states choice of law
provisions. any actions arising from this license or the use of this
software shall be commenced and maintained in the brd (frg).

* limitations on installation and use of the software:

you may lend or copy and distribute the software free of charge to other
people provided always that the terms and conditions of this agreement
accompany to each copy so lent or distributed.

you must not charge a fee, exchange goods or services, barter or otherwise
profit in a commercial way from the lending, leasing, selling or
distribution of the software.

you may not modify, translate, reverse engineer, decompile, dissassemble any
part of the software or create derivative works based on the software.

* disclaimer of warranty:

this software is provided "as is" without warranty of any kind, either
expressed or implied, including, but not limited to the implied warranties
of merchantability and fitness for a particular purpose. the entire risk as
to the quality and performance of this software is with you. should the
software prove defective, you assume the entire cost of all necessary
servicing, repair, and correction.

the author does not warrant that the functions contained in the software
will meet your requirements or that the operation of the program will be
uninterrupted or error free.

under no circumstances and under no legal theory, tort, contract, or
otherwise, can the author be liable to you or any other person for any
indirect, special, incidental, or consequential damages of any character
including, without limitation, damages for loss of goodwill, work stoppage,
computer failure or malfunction, or any and all other commercial damages or
losses. in no event will the author be liable for any damages in excess of
the amount the author received from you for a license to the software, even
if the author should have been informed of the possibility of such damages,
or for any claim by any other party. this limitation of liability shall not
apply to liability for death or personal injury to the extent applicable law
prohibits such limitation. furthermore, some jurisdictions do not allow the
exclusion or limitation of incidental or consequential damages, so this
limitation and exclusion may not apply to you. no dealer, agent, or employee
of the author is authorized to make any modifications, extensions, or
additions to this warranty.

title, ownership rights, ownership of all derivative works, and intellectual
property rights in the software remain with the author. the software is
protected by copyright and other intellectual property laws and by
international treaties. title and related rights in the content accessed
through the software is the property of the applicable content owner and may
be protected by applicable law. this license gives you no rights to such
content.

* termination of the license

the license will terminate automatically if you fail to comply with the
limitations described herein. on termination, you must destroy all copies of
the software and documentation. your obligations to pay accrued charges and
fees shall survive any termination of this agreement.

* acknowledgement

you acknowledge that you have read this agreement, understand it and agree
to be bound by its terms and conditions. you further agree that it is the
complete and exclusive statement of the agreement between yourself and the
author.

Credits

Search for regular expressions is based on the Regex Library by Niche Software.
Note: I modified the original code to (hopefully) work with different character sets and unicode files. After some (little) testing I decided to use the code I modified in Tiny Hexer. Please inform me if searching for regular expressions does not work as expected. Do not blame the author of the original library for possible mistakes in my derivative implementation!

Boyer-Moore-Horspool search algorithm based on Angus Johnson's TSearch Delphi VCL.
Note: I modified the original code to work with wildcards. After successful testing, I decided to use this modified code. Please inform me if searching does not work as expected. To disable the new searching algorithm, see the FAQ.

Windows XP themes support by Mike Lischke's TThemeManager Delphi VCL (as of version 1.0.1.30 of Tiny Hexer, Borland Delphi 7 is used which has built-in support for XP themes).

The scripting engine has been written using a derivative of the unit expression.pas found on http://www.blacky.co.nz/free/index.htm (broken link).

HTML help support by Delphi units written by The Helpware Group.

The SHELL() function is based on the unit ConsoleApp.pas by Martin Lafferty.

The editor is a special version of my component TMPHexEditorEx, available at http://www.mirkes.de/en/delphi/vcls/hexedit.php. Many people helped me with this component, so credits go to John Hamm, Christophe Le Corfec, Philippe Chessa, Daniel Jensen, Shmuel Zeigerman, Vaf, Eugene Tarasov, FuseBurner, Motzi, Martin Hsiao and others.

The graph in the "Statistics" dialog is drawn using the free TMathImage component by Renate Schaaf (broken link).

RTF export is based on the unit Ctltortf.pas by K. Nishita.

The setup is created using Jordan Russell's famous Inno Setup and Bjørnar Henden's ISTool.

Executable file's sizes are shrinked using Jordan Russell's StripReloc (not an "Exe compressor"!).

Unicode enabled "Value editor" window using TNT Delphi unicode controls by TNT Software Products.

Faster file access during script execution due to the gpHugeFile.pas unit copyright ©2003, Primoz Gabrijelcic.

Memory operations are optimized using Pierre le Riche's brilliant Delphi memory manager FastMM 4, John O' Harrow's System.Move() replacement FastMove (broken link) and Gabriel Corneanu's FastSys/FastObj units.

Special thanks go to all the people who sent bug reports, specs, scripts and suggestions to me, e.g. Bill Blankenship, Andras Stark, Dave Jordan, MT, Uwe Nolte, Serge Matovic, Norbert Schulze, Johann Thomas, Bob Jones, Dirk Viehöver, Richard Butler, Christoph von Wittich, Ward van Tichelen, Lars Römheld, Randy Scarborough, George Schizas, TheDutchJewel, Jürg Leckebusch, Bryce Schober, Noam Tamim, Richard Butler, John Ashburton ... Many thanks for your support!

About the author

This free binary file editor has been written by Markus Stephany, 66132 Saarbrücken-Bischmisheim, Saarland, Germany. It is written using Borland Delphi™ 7 Professional. You can reach Markus via EMail at mailto:tinyhexer@mirkes.de and via ICQ at 275360637.


Tiny Hexer - Version History

On this page changes between the versions of Tiny Hexer are listed.
1.7.1.2, June 05, 2006:

  • Bugfix: Slightly improved macro recording (but still buggy...)
  • Bugfix: If some tool windows were displayed, Tiny Hexer didn't correctly move to the background when deactivating
  • Bugfix: There was a bug in the Find/Replace dialog. When using the "Replace All" function together with regular expressions, not all data had been replaced
  • Bugfix: In synchronized view, the second cursor had not been displayed correctly
  • Bugfix: Termination of Tiny Hexer took ages when it ran under an administrative account
  • Bugfix: Added confirmation queries when navigating to different disk sectors and there were unsaved modifications in the editor
  • Added a Tiny Hexer Medium Edition (without scripting and plugins, it will supersede the Small Edition in the forseeable future)
  • Added "Readonly" checkbox in Open disk image/large file and Open drive/partition dialogs
  • Added icons and toolbar buttons to Tiny Hexer Scripts and external tools
  • In the Open disk image/large file dialog it's possible to manually enter any sector size
  • Speeded up Tiny Hexer a bit by using the FastObj library
  • The former Type Inspector has been replaced by a more sophisticated Status Window tool
  • New command File/New (Advanced)
  • Changes in Tiny Hexer Script:

    • added function: BYTESTRING()
    • added optional default parameter to ASKOPENFILENAME() and ASKSAVEFILENAME()
    • added command: DLLFUNC for calling stdcall functions in DLLs
1.7.1.0, April 15, 2006:

  • Removed the "maybe" setting of the find text and replace text checkboxes in the Find/Replace dialog
  • Modified status bar to show virtual offsets
  • Changed the Edit/Goto command for allowing virtual offsets
  • The problem with Data Execution Prevention on XP SP2 should be solved
  • Big Endian setting in the File statistics dialog
  • Similarity comparison
  • Support for IBM single and double precision floating point data
  • Added in the Structure viewer: Script selector, "From Zero" button
  • Added Type inspector, Editor finder and Calculator tools
  • Support for alternate data streams on NTFS
  • Settings are no longer stored in the registry but in a database file under %Application Data%\mirkes.de\Tiny Hexer\<Major version>\settings.dat
  • The positions of MDI child windows are no longer persistently stored (which was useless)
  • Alternate selection/position display (relative to EOF)
  • Added the ability to record macros (key strokes and menu commands) as Tiny Hexer Scripts
  • Added a File properties window
  • Now you can use mathematical expressions in the Value editor
  • Changes in Tiny Hexer Script:

    • Added new data types: SIGBYTE, SIGWORD, SIGLONGWORD, SINGLE, DOUBLE, EXTENDED and COMP
    • Changed behaviour of TEXT2DATA() and TEXT2DATABE() in the third parameter
    • Abbreviation # for the CALL() function
    • Added GOTOEOF and SENDCHARACTERS file properties
    • Changed REG... functions to allow for using the new settings database to store/retrieve options
    • Added functions and special variables: ABS(), ARCCOS(), ARCSIN(), ARCTAN(), BIN(), CEIL(), COMP(), COS(), COT(), DEC(), DOUBLE(), EXP(), EXTENDED(), FLOATTOIBM4(), FLOATTOIBM8(), FLOOR(), FRAC(), FRANDOM, HEX(), IBM4TOFLOAT(), IBM8TOFLOAT(), INT(), ISFLOAT(), LOGN(), LOG10(), MAX(), MIN(), OCT(), ODD(), PI, ROUND(), SIGN(), SIN(), SINGLE(), SQRT(), TAN(), TRUNC()
    • Added power (**) and floating point division (//) operators
1.6.0.4, May 22, 2005:

  • Changed print progress display
  • Non-modal plugin windows now are also minimized when Tiny Hexer itself is minimized
  • When working in the character pane, the secondary cursor frame in the hexadecimal pane now surrounds the whole data value, not just the first halfbyte
  • Speeded up the "Replace All" command in the Find/Replace window again (now the command uses temporary files)
  • New option "Path for temporary files"
  • The menu command "File/Disk/Write changes" now is always available, not just after changing an option.
  • New menu command "Edit/Clear undo buffer"
  • New menu command "View/Editor offset format/Absolute offset"
  • More precise drive sizes in the Drive/Partition dialog. Now Tiny Hexer tries to read beyond the drives to find out their real sizes in addition to the drive geometry record returned by a Windows API function (as that seems to be quite inaccurate)
  • When editing disk sectors, you can use the arrow keys at the beginning and the end of the currently loaded sectors to navigate to the preceding or succeeding sector, respectively.
  • Better keyboard support in the Value Editor
  • Enhanced Convert dialog: Now you can also convert WORD, LONGWORD and SIGQWORD values from Little Endian to Big Endian and vice versa
  • New menu command "File/Disk/Open disk image or large file as drive"
  • Fixed some minor bugs
  • Changes in Tiny Hexer Script:

    • Added QRANDOM special variable
    • Fixed a bug that let functions return wrong SIGQWORD results
    • Added Structure Viewer scripts for NTFS, FAT16 and FAT32 structures (thanks to Bill Blankenship!)
    • Added special variable GETTEMPFILENAME
1.6.0.2, March 16, 2005:

  • Fixed a bug which prevented Tiny Hexer from running on systems without SSE support
  • Fixed an access violation in the Edit\Undo command
  • Fixed a bug in the "List differences" script ("Missing IF" error message)
  • Fixed some other minor bugs
  • Improved Disk Editor: The first sector to be read can be specified, more than 64 MB of data can be read at once, less memory usage during reading/writing
  • Improved Read Process Memory dialog: A memory limit can be specified
  • Speeded up the "Replace All" command in the Find/Replace window
  • Improved Motorola S-Record and Intel Hex import/export
  • Added commands to import data from the clipboard and to import data into the current file
  • Changes in Tiny Hexer Script:

    • Added GUI functions to show user defined dialogs
    • Added custom editor properties and a related option
    • Changed the formatting of Import/Export scripts
    • Added parameter breakonwhitespace to the FILEREADTEXTLINE command
    • New special filename "::Buffer" in the FILEOPEN() function
    • Implemented wildcard filename in the INCLUDE command
    • Most functions can be used like commands, i.e. functions which have no equally named command counterpart can be used as first keyword in a script line.
    • More flexible TEXT2DATA function
    • Added TEXTCUT(), HEX2BIN(), BIN2HEX(), TEXT2DATABE(), DATA2TEXTBE() functions
1.6.0.0, January 14, 2005:

  • The Plugin interface has been redesigned, so older (= pre 1.6) Third Party plugins must be recompiled using the current Plugin SDK to work with Tiny Hexer 1.6
  • The Unicode view menu entries now explain why they are disabled on odd-sized files
  • Added in Tiny Hexer Script: ESCAPEHTML(), FILEREADBE() and FILEWRITEBE() functions; Here Document string literals; TITLE directive; localizable scripts; Height, Left, Raw, Top, Visible and Width properties in the Structure Viewer '::Browser' file
  • Added Tools/Scripts menu
  • Scripts can now have "Graphical User Interfaces" by using HTML forms in the Structure Viewer
  • Added a plugin for extraction of character strings from binary files
1.5.0.20, December 24, 2004:

  • Rearranged the Global Options dialog and added an option to disable automatic vertical tiling when synchronizing views (and comparing files)
  • Changed the code to synchronize views to avoid high cpu load
1.5.0.18, December 21, 2004:

  • More sophisticated Open Drive/Partition dialog (relations between logical and physical hard drive volumes and also drive type, drive size and sector size are displayed)
  • Added support for RTF, plain text and unicode text export
  • Another attempt to fix some access violations when closing Tiny Hexer...
  • A few other minor changes
1.5.0.16, November 18, 2004:

  • Fixed an error message when replacing with no data (removing) in the Find/Replace dialog and the replacement text mode has been set to a value different from "(Current mode)"
  • Fixed another bug in the Find/Replace dialog (if the find and replacement data have the same size, the "Replace" button is not disabled after replacing, so pressing it again replaces the next occurence of the search pattern without displaying it first)
  • Files opened readonly are marked with the text " (readonly)" in the title bar
1.5.0.14, November 12, 2004:

  • The status of the No Editing mode is correctly restored when reopening a file
  • In No editing mode it is no longer possible to cut data from an editor via OLE Drag and Drop, also Redo and Undo are disabled
  • In the Find/Replace dialog you can now search for/replace with data in a different character translation than the current one, that is you can e.g. search for unicode text in an ansi file
  • In the Convert dialog you can now also convert from/to Unicode
  • Fixed another error message when closing the "Global Options" dialog
  • Added in Tiny Hexer Script: TEXTCONVERT() function
  • Changed mouse selection in Insert mode, now it's more text editor-like
1.5.0.12, October 27, 2004:

  • Searching in the Read Process Memory dialog now can search for the data in the selected process and all processes in the list following the selected one
  • Changed the behaviour of the Convert dialog (Now you can choose whether to convert all data or just the selected one)
  • The "Apply" button in the Value Editor now is always disabled if the editor is in No Editing mode
  • The statusbar now shows the text "No editing" rather than "OVW" if the editor is in No editing mode
  • Added command line switches /noed (No editing mode) and /sp (script parameters)
1.5.0.10, October 09, 2004:

  • New options Explorer integration and Disk editing: Write access

1.5.0.8, September 28, 2004:

  • Fixed bogus bookmark icons
  • Added Insert Partial File and Paste over file commands
  • Added a calculator tool
  • Some edit boxes that expect numerical input now have a button to show the calculator
  • Added in Tiny Hexer Script: INPUTNUMBER() function, CALL() function, ARGC special variable, TYPEOFSTACK special variable
  • Changed in Tiny Hexer Script: RETURN can now return a value if a subroutine has been called using the CALL() function, better error handling, plugins called by scripts now can manipulate script variables
1.5.0.6, August 30, 2004:

  • Bugfix in Tiny Hexer Script: The CMD.EditFindStore external command sometimes removed the first entry from the position list
  • Corrected colors of hex editors in some dialogs
  • Added in Tiny Hexer Script: UNDO directive, ASKDIRECTORY() function
1.5.0.4, August 29, 2004:

  • The "View/Highlight values" menu item is checked only if highlighted data values are defined
  • Added a "Configure" button to the Plugins page in the Global Options dialog
  • A ruler can now be printed on top of each page
  • The active pane (hexadecimal/characters) can be painted using a different background color
  • Items in the "Select Editor" dialog are sorted
  • Fixed an error message after closing the "Global Options" dialog
1.5.0.2, August 14, 2004:

  • Rewritten large parts to support plugins (a plugin SDK for Borland Delphi and the delphi sources of some of the plugins are included)
  • Added a Plugins page to the Global Options dialog
  • Some features of Tiny Hexer are now stored in plugins "[filename].thp", not in mpth.exe itself anymore. They are marked with a green asterisk (*) in this help file
  • The language selection menu now marks the current language and does not recommend a restart if the language is not changed
  • Added in Tiny Hexer Script: REGWRITE, LANGUAGE_EXT, REGREAD(), SELECTEDITORFILE(), TEXTLINE() and TEXTLINECOUNT()
  • Extended in Tiny Hexer Script: The EXTERN command can be used to execute functions in Tiny Hexer plugins
  • Added the macros $(SIZE) and $(WAIT) in the Tool properties dialog
  • Slightly modified the format of configuration files (mostly backward compatible, older releases of tiny hexer might not be able to read all settings)
  • Files will not be displayed in synchronisation mode after comparison if they do not differ
  • Fixed a bug in the "Choose Editor" dialog, so now a file can just be doublecklicked to get selected
  • The caret was not set properly when switching from hexadecimal to character pane if no data was in the editor
  • Speeded up file access in Tiny Hexer Script
  • Changed naming of untitled editor windows (two or more files could had have the same title)
  • The Open Drive/Partition dialog now also displays logical hard drive volumes
  • Added Paste to New and Find Editor commands
  • Added an HTML Export plugin
  • Added the ability to mark specific data values using different colors
  • Tiny Hexer Small Edition is compiled using a smaller runtime library (smaller size, needs less resources)
1.0.1.30, June 26, 2004:

  • Hopefully fixed a bug that could raise an error message when starting another instance of Tiny Hexer while the previous instance was running
  • Fixed a bug in the Find Dialog that allowed searching if the "Find Text" checkbox was unchecked and invalid hex data was entered
  • Switched from Delphi 6 to Delphi 7
  • Added an option to prevent Tiny Hexer from creating an unnamed editor window at startup (so the registry patch available in the faq is not necessary anymore)
  • The program language can now be switched manually from the Options menu
1.0.1.29, June 16, 2004:

  • Fixed an exception in the File statistics window when only a few bytes of data were used
  • Fixed missing icons in the Window Bar
  • Fixed wrong separator width after customizing the Tool Bar buttons
  • The Window Bar is now displayed only when two or more files are opened
  • The Ruler now displays numbers using the current Editor Offset Format
  • The caret is set to a bottom line in No editing mode
  • The File statistics window supports more data types
  • The Editor Offset Format can be adjusted independently for each open file
  • Rearranged View and Options menu
  • Split the Options dialog into a global and an editor specific options dialog
  • View/Synchronize command added
  • Tools/Compare/Compare command changed to synchronize the view of the compared editors
  • The Value Editor now can also display and edit 16 bit unicode characters (NT platforms only)
1.0.1.27 - 1.0.1.28, June 07, 2004:

  • Fixed some drawing bugs
  • Using the mouse wheel scrolls a page rather than a single line
  • Implemented a Window Bar
  • The scrollbars in editor windows have proportional thumbs now
  • Added an option to configure default Insert/Overwrite mode
1.0.1.26, May 30, 2004:

  • Fixed a bug that caused all files to be opened read-only
  • The "Copy" popup menu command in the Structure Viewer now (hopefully) works
  • Printing the Structure Viewer contents now produces more meaningfull page headers and footers
  • Fixed some minor format strings related bugs
1.0.1.25, May 16, 2004:

  • Added in Tiny Hexer Script: ERRORHANDLER, ERRORLINE, ERRORMESSAGE, ERRORNUMBER, IFGOTO
1.0.1.24, May 09, 2004:

  • Fixed a bug that could raise an error message when starting another instance of Tiny Hexer while the previous instance was terminating
  • Slightly modified the format of configuration files (but still backward compatible)
  • Added an option to force maximized creation of new editor windows
1.0.1.23, May 05, 2004:

  • When loading settings from a file, tiny hexer now searches for a specific value in the configuration file. If this value is not found, a warning is displayed (to distinguish Tiny Hexer config files from other .ini-files which could mess up the Tiny Hexer registry key).
  • Tiny Hexer isn't associated with all file types anymore (see the FAQ for details)
  • Tiny Hexer can now be forced to load a default configuration file at startup (see the FAQ for details)
1.0.1.22, May 02, 2004:

  • Hopefully fixed a possible bug ("Invalid property value") on startup (Problem was reported anonymously without enough details)
  • The "File/Open Group" command can get cancelled using the ALT or ESC key
  • Fixed active editor window if the "File/Open group" command shows an error message
  • Removed some stuff from the small edition (toolbar configuration, images, keyboard mapping, configurable menu shortcuts, start/stop-script) to further reduce its size and resource usage
1.0.1.21, May 01, 2004:

  • Shrunk the size of Tiny Hexer small edition
  • The "Open in Tiny Hexer" shell context menu could lead an already running instance of Tiny Hexer to hang if it was showing a modal dialog
1.0.1.20, Apr. 28, 2004:

  • Fixed a bug that brought up an error message when resizing the "File/Statistics" window
  • An error message is now displayed when some files couldn't get opened via drag and drop
  • Added the "File/Open group" and "File/Save Group" commands
1.0.1.19, Apr. 25, 2004:

  • The "File/Open" command now allows to open multiple files at once
  • Added the "File/Reload" command
  • Added the "File/Statistics" command
  • Added the ability to search for regular expressions
  • The Position List and per-file-bookmarks do store selections, not just positions
  • Position 0 can now get bookmarked
  • Fixed a bug that caused Tiny Hexer to forget the Find Dialog's settings
  • Fixed a bug that caused Tiny Hexer to crash when editing bookmarks
1.0.1.18, Jan. 11, 2004:

  • "Insert nibble" and "Delete nibble" commands disabled in fixed filesize mode
1.0.1.17, Dec. 24, 2003:

  • Added a Position list window
  • Added in Tiny Hexer Script: AbsolutePosition, AbsoluteSize, ASKFINDOPTIONS(), POSITIONS(), POSITION_ADD(), POSITION_COUNT(), POSITION_DESC, POSITION_SELECTED(), CMD.EditFindStore, CMD.PosListDeleteSelected, CMD.PosListLoad, CMD.PosListSave, CMD.PosListSelectAll, CMD.PosListShiftSelected, CMD.ToolsPosList
  • Added a "Find All and Store" command to the Edit Menu
  • Added Help menu commands for direct access to version history and the Tiny Hexer Script reference
  • Added a "Print" command in the Structure viewer
  • The status bar panels are now sized automatically
  • Some commands (like "Find next") sometimes were not available when they should have been
  • Some other minor code fixes
1.0.1.16, Dec. 16, 2003:

  • Changing a data file's size via script is undoable now
  • "Fixed file size" option cannot be changed when editing disk sectors or process memory
  • The statusbar now shows whether a file's size is fixed or not
  • Two file properties added: FillByte and FixedSize
  • Script for file resizing added
1.0.1.15, Dec. 10, 2003:

  • Fixed a bug when doublecklicking the ruler bar (sometimes line 0 -1 has been displayed)
1.0.1.14, Dec. 07, 2003:

  • Removed some code from the small edition, so it is even smaller now
  • On closing editor windows containing unsaved changes, Tiny Hexer know displays the correct dialog when editing disk data or process memory blocks (not just the "Save As" dialog)
1.0.1.13, Nov. 29, 2003:

  • The new search algorithm now also works in unicode mode
  • If the Open process dialog's hex editor is in unicode mode, the process range will be opened in tiny hexer in unicode mode automatically
  • Changed behaviour of shortcuts, so shortcuts like 'CTRL+C' work in non modal active windows
1.0.1.12, Nov. 27, 2003:

  • Faster searching by using a Boyer-Moore-Horspool algorithm
    Note: I modified the original algorithm to work with wildcards. After successful testing, I decided to use this modified code. Please inform me if searching does not work as expected. To disable the new searching algorithm, see the FAQ.
  • During disk editing, the absolute address on disk is also displayed on the status bar
  • Bookmarks now store absolute disk addresses
  • "Goto Sector" in the disk menu renamed to "Goto sector/position", now byte based absolute disk positions can be entered in this dialog
  • The wildcard in the Find dialog now can be typed as a character, not only a hex value
  • Some more drawing bugs on themed XP fixed
  • More settings are now saved when using the "Options/Save Settings" command (file settings, search/replace history...)
1.0.1.11, Nov. 23, 2003:

  • Improved Windows XP themes support
  • Some other GUI fixes
  • Search/replace can be cancelled by pressing the ALT key
  • More than 4096 disc sectors can be read at once
  • Whole partitions/volumes can be searched for data
  • A default value for disk sectors to be read at a time can be set
  • Progress bar during search/replace
1.0.1.10, Nov. 15, 2003:

the Drive/Partition dialog now allows you to show more than one single sector at once in the hex editor window.
1.0.1.9, Oct. 24, 2003:

changed the Drive/Partition dialog's list to display a horizontal scroll bar if necessary.
1.0.1.8, Oct. 17, 2003:

added TEXTCHOP() function, added commands to compare two open files
1.0.1.7, Oct. 14, 2003:

somewhat faster scripting engine, added output parameter to the SHELL() function, added TEXTBOX command
1.0.1.0 - 1.0.1.6:

some minor bugs fixed, german language user interface added.


Frequently asked questions

Frequently asked question (FAQ)

On this page some frequently asked questions about Tiny Hexer are answered.

Bugs:

Bugs already fixed in Tiny Hexer are listed in the version history.

General:

How can I prevent files from being opened in Tiny Hexer when accidentally doublecklicking them in Explorer?

You can switch the integration of Tiny Hexer into Explorer's context menu from the "Global options" dialog.

How can I prevent Tiny Hexer from creating an unnamed editor window?

There are two ways to start Tiny Hexer without showing an empty document window:

  • Start Tiny Hexer using the /n command line switch.
  • Switch off the option "Open a new editor window at startup" in the "Global options" dialog.

The "View/Character translation/Unicode..." menu entries are sometimes disabled. Why?

Unicode mode is disabled on odd sized files (i. e. files whose size is not divisible by two without remainder). As Tiny Hexer can only display 16 Bit Unicode, the file must consist of whole 16 bits (= 2 bytes) values.

Tiny Hexer Small Edition:

How can i use preconfigured settings in Tiny Hexer SE on BartPE?

As of version 1.7, Tiny Hexer does not use the registry any longer to store its settings. They are stored in a "mpth.dat" database file (located in the temporary directory in the Small Edition). To be able to preconfigure Tiny Hexer Small Edition, it looks for a file "mpth_small.ini" in its program folder and stores the settings from this file in the mpth.dat settings database if the database file does not yet exist. To create such a preconfiguration .ini file, use the "Options/Save settings" command in Tiny Hexer and select the .ini file type (use the full version to create the settings file if possible, it can store more settings like e.g. toolbar button configuration). The distribution package of Tiny Hexer Small Edition includes an example (look at mpth_small.ini).

Tiny Hexer Small Edition does not start on WinPE!

There is a bug in version 1.0.1.11 of mpth_small.exe which prevents it from working under WinPE. Please upgrade to the latest version.

Disk editing:

What are the differences between sectors, absolute disk positions and caret positions?

Tiny Hexer cannot operate on a whole drive or partition for the time being, so you have to load a part of the disk's data into memory to edit that data.
Disk data is stored in sectors, each volume has a specific sector size. Usually hard disk volumes have a sector size of 512 byte, CDROM sectors contain 2048 byte of data.
So if you open a hard drive volume and select an amount of 16 sectors at once, 16*512=8192 byte of disk data are displayed at once in the editor.

Using the "File/Disk/Goto sector/position" menu command you can either navigate to a specific sector or an absolute position. If you choose an absolute position, the sector representing this position is loaded into the editor and the editor's caret will be set to the position relative to the sector that matches the selected absolute position.
An example: Choosing the absolute position 4711 on a hard disk (sector size 512 byte) will load sector 9 into the editor and set the caret to offset 103 as 4711 divided by 512 results in 9 (sector) and 4711 modulo 512 results in 103 (offset).


Regular expressions

On this page I will try to explain the regular expression based search in Tiny Hexer.
  • Overview
  • Definitions
  • Notes

Overview

You can choose to use Regular expressions in Tiny Hexer's Find/Replace window to perform powerful searches. If you ever tried the wildcards "*" or "?" in a directory listing (like "dir *.txt"), you already have used a simple form of regular expressions.

Regular expressions in Tiny Hexer, however, can be much more powerful than those filename wildcards.

Imagine the following: There's a binary file containing address records, but it's corrupted somehow and cannot be opened anymore in the address book application. Now you need the address of a Mr. Johnson, Jonson, Jenssen or is it Jensen? Unfortunately you are not sure about the exact name, and you cannot find his address anywhere else. But you know that the record is stored in this binary address record file. After loading this file into Tiny Hexer you could do sequential searches for all those names in the data, but what if he's called Jehnsen or Jonnsen? Using the regular expression J[oe]h?n+s+[oe]n you can search for all these names at once.

Well..., how does it work? I'll try to answer this question in the following section.

Definitions

Regular expressions are sets of elements used to match patterns of data, that is each element (character, set or group) in a regular expression can match none, one or more characters or groups of characters (depending on branches and modifiers).

Characters

The simplest element is an ordinary character ("a", "b"...). This element matches exactly that character in the data. In the example above the character J is used to find the first character of the name (Johnson, Jensen...). Character elements can be written in hexadecimal form by being prefixed with the \x escape to allow searching for binary data (e.g. \x0A for the character with the binary value of 0A hex = 10 dec). Some characters that have a special meaning in regular expressions must be escaped using the backslash \ (unless they are written in hexadecimal notation), those characters are ., *, \, +, (, ), ?, |, [ and ].

Sets

Sets are used to match either one of the characters included in the set. In the example above, the set [oe] is used to match either the character "o" (Jon.../...son) or the character "e" (Jen.../...sen). Sets are embedded in brackets ([...]).You can include ranges of characters in sets by writing a hyphen between the first and the last value, e.g. to match alphanumerical characters, you may write [0-9a-zA-Z]. You can also use negated sets by putting the circumflex (^) after the opening bracket: If you want to search for any data except alphanumerical characters, you may write [^0-9a-zA-Z].

The following predefined sets exist (they do not need to be embedded in brackets):

  • "." matches any value (00 hex - FF hex)
  • "\a" matches any alphabetic character ('a' - 'z' and 'A' - 'Z')
  • "\d" matches any digit ('0' - '9')
  • "\w" matches any alphanumerical character ('a' - 'z', 'A' - 'Z' and '0' - '9')

Groups

Groups connect sequences of elements. They are used in conjunction with modifiers and branches (see below). Element groups are embedded in parentheses ((...)). So if you want to search for either "John" or "Jane", use the regular expression (John|Jane), if you want to search for either "John" or "Jonny", you might use Joh?n(ny)?.

Branches

Branches allow to search for either one of alternatives of groups or elements. They work like logical ORs. All elements of a branch have to be separated by a pipe character (|). So if you want to search for either "John Smith", "John Taylor" or "John Q Public", you can use the regular expression John (Smith|Taylor|Q Public).

Modifiers

Modifiers tell the matcher how often the preceding group, element or set must occur in the data.

The following modfiers exist:

  • "*" the preceding group, element or set might be present any time (also zero times), e.g. Jon*y matches "Joy", "Jony", "Jonny" and "Jonnny".
  • "?" the preceding group, element or set might be present one time (also zero times), e.g. Jon?y matches "Joy" and "Jony", but not "Jonny" or "Jonnny".
  • "+" the preceding group, element or set must be present at least one time, e.g. Jon+y matches "Jony", "Jonny" and "Jonnny", but not "Joy".

The modifier ? has a different meaning if it's the first character in the regular expression: It tells the matcher to be "non-greedy", that is the modifiers "eat" as little characters as possible to match the pattern. An example: The pattern T.+s finds "This is" in the text "This is a text", the pattern ?T.+s just finds "This".

Notes

  • The search for regular expressions is based on the Regex Library by Niche Software.
    I modified the original code to (hopefully) work with different character sets and unicode files. After some (little) testing I decided to use the code I modified in Tiny Hexer. Please inform me if searching for regular expressions does not work as expected. Do not blame the author of the original library for possible mistakes in my derivative implementation!
  • In contrast to the usual behaviour of the . set in regular expressions, the Tiny Hexer version matches all data values, not only alphanumerical characters.
  • The common regular expression modifiers ^ (match line start) and $ (match line end) are not correctly implemented in my modified version of the regular expression library and thus should be avoided.
  • When searching in unicode files, sets do not work if they contain characters with an unicode value > 00ff hex, e.g. [€¢] will not match the Euro sign. In this case you should rather use grouped branches: (€|¢)
  • There might be further problems with matching regular expressions if the data file is in unicode format or in a character set other than Windows ANSI. This is due to some quick 'n' dirty hacks i made in the RegEx library derivative used in Tiny Hexer.


Main window

This topic gives some information about the menus and controls in the main window.
  • The menu
  • The toolbar
  • The window bar
  • The status bar

The menu

  • File menu
  • Edit menu
  • View menu
  • Tools menu
  • Options menu
  • Bookmark menu
  • Window menu
  • Help menu

The toolbar

The toolbar gives you quick access to some of the menu commands. You can customize the buttons on the toolbar by doublecklicking an unoccupied part of the toolbar or using the Options/Customize toolbar command.

The window bar

The window bar displays a tab for each editor window. By left clicking a tab, the corresponding editor window is activated, by right clicking a tab, the system menu of the editor window is displayed. The visibility of the window bar can be toggled using the View/Show window bar command.

The status bar

The statusbar consists of ten segments:

  1. The first segment displays the size of the file in the active editor
  2. The second segment displays the current caret position in the active editor window. If a range of disk sectors is currently being edited, the absolute address on disk the caret is pointing to is also displayed (in square brackets)
  3. The third segment shows the start and end position of a selected block
  4. The fourth segment shows an asterisk (*) if the active file has been modified
  5. The fifth segment shows an "R" if the active file has been opened readonly
  6. The sixth segment shows an "F" if the active file's size is fixed (when editing disk sectors or process memory blocks or when it has been configured in the "Options" dialog)
  7. The seventh segment tells you whether the current editor is in insert, overwrite or no editing mode
  8. The eighth segment tells you the current character translation mode (like ANSI (WIN), EBCDIC (BCD) and so on)
  9. The ninth segment shows "REC" if you're currently recording a macro script
  10. The last segment is a multiple purpose field, it shows hints and load/save/script progress


File menu

This topic describes the commands in the file menu.
  • New: Open a new, empty editor window
  • New (Advanced): Open a new editor window with specific properties defined in the New file properties dialog
  • Open: Select one or more files in a dialog and open them in Tiny Hexer
  • Reopen*: This submenu contains a list of previously used files; by clicking an entry the file is opened in a new editor window
  • Reopen/Cleanup*: Remove non-existing files from the "Reopen" menu
  • Insert file: Insert a file from disk at the current position in the active editor window. If a block of data is currently selected, this block will be replaced by the file's data
  • Reload: Discard all changes and reload the current file from disk again
  • Open group*: Open a group of files previously stored using the following command
  • Save group*: After selecting a group of open files in a dialog, this group is stored in a file. Using the previous command all files in this group can be opened again later
  • Insert partial file: Insert a part of a file on disk at the current position in the active editor window. If a block of data is currently selected, this block will be replaced by the partial file's data. You can specify the position and size of data to be inserted in the "Insert partial file" dialog.
  • Paste over file: Paste the contents or selection of the active editor window over the data of an existing file on disk at a specific position. After selecting the target file, you can choose the position in the "Paste over file" dialog.
  • Disk: This submenu contains commands to work with raw data on disk partitions, CDROM and floppy disks (Windows NT/2000/XP only)
  • Process: This submenu contains commands to read and write memory in other processes:

    • Read process memory: Displays the "Read process memory" dialog, where you can select a memory block in another process to be opened in Tiny Hexer
    • Write process memory: After modifying a process memory block in the editor, you can write back the data to the other process. The "Write process memory" dialog is displayed to choose some options. This is a dangerous command as you might crash the process. If you write nonsense data to a system process, the whole system might crash!

  • Save: Save a modified file back to disk. Automatic backups can be configured in the "Global settings" dialog (auto backups are enabled by default)
  • Save as: Save the active file under a different name
  • Save selection: Save the selected data block to a file on disk
  • Import*: This submenu contains commands to choose data from a file or the clipboard in various formats (e.g. Intel Hex or Motorola S-Record) in the "Import" dialog to be opened in a new or the current editor window
  • Export*: Save the current file in a specific format (e.g. hex text) after selecting the export type in the "Export" dialog
  • Print setup: Show Windows' printer setup dialog to choose a printer and its settings
  • Print: Open the "Print preview" dialog that allows you to print the current file
  • Statistics*: Display some statistical data for the current file or selection in the "File statistics" dialog
  • Properties*: Show the "File properties" dialog which allows you to view and modify file sizes, timestamps and file attributes
  • Close: Close the active editor window
  • Close all: Close all open editor windows
  • Exit: Leave Tiny Hexer


File/Disk menu

This topic describes the commands in the file/disk menu (Windows NT/2000/XP only, you might need administrative privileges to gain direct access to drives).
  • Open drive: Displays the "Open drive/partition" dialog, where you can select a physical drive, a disk partition, a CDROM or a floppy disk that is displayed sector by sector in an hex editor window.
    Note: When editing disk sectors, you can use the arrow keys at the beginning and the end of the currently loaded sectors to navigate to the preceding or succeeding sector, respectively
  • Open disk image or large file as drive: Displays the "Open disk image or large file" dialog, where you can select a disk image to be edited in Tiny Hexer sector by sector. This command can also be used to edit files bigger than 2 GB in sector mode, as those large files cannot be opened in Tiny Hexer directly
  • Load first sector: Loads the first sector of the opened drive, partition or media into the editor window
  • Load previous sector: Loads the previous sector of the opened drive, partition or medium into the editor window
  • Load next sector: Loads the sector following the current one into the editor window
  • Load last sector: Loads the last sector of the opened drive, partition or medium into the editor
  • Goto sector/position: Here you can enter a disk/partition sector number that should be opened in the editor. This number may be prefixed by a minus "-" or plus "+" sign to enter a sector range relative to the current sector or by a greater than sign ">" to enter an amount of sectors relative to the last sector.

    You may also enter an absolute position on disk (byte based, not sector based) by prefixing the value by an exclamation mark "!".
  • Write changes: After modifying a sector in the editor, you can write back this changed sector to disk. (This command can be very dangerous. Tiny Hexer does not lock the sectors being edited, so Windows might modify the disk sector after loading it into Tiny Hexer. In this case writing back the sector to disk leads to inconsistent disk data and might damage the whole filesystem! Use this command absolutely at your own risk, you have been warned!!!)


Edit menu

This topic describes the commands in the edit menu.
  • Undo: Undo modifications
  • Redo: Reapply the latest undone modification
  • Clear undo buffer: When clearing the undo buffer of a file, all previously recorded modifications become permanent, so the "Undo" command is disabled until the file is modified again
  • Copy: Copy the current selection to the clipboard
  • Cut: Cut the current selection to the clipboard
  • Paste: Paste clipboard contents into the active document. If the clipboards contains third party data, a dialog will be shown which allows you to select the data type
  • Paste to new*: Paste clipboard contents into a new document. If the clipboards contains third party data, a dialog will be shown which allows you to select the data type
  • Delete: Delete the current selection
  • Goto: Shows a dialog where you can type a position to set the cursor to in the active document. This number may be prefixed by a minus "-" or plus "+" sign to enter a position relative to the current cursor position, by a greater than sign ">" to enter a position relative to the file's end or a n exclamation mark "!" to enter a virtual offset
  • Select: Shows a "Selection" dialog where you can enter a block of data to be selected
  • Store in position list: Adds the current cursor position/selection to the Position list
  • Select all: Select all data in the active document
  • Insert nibble: Inserts half a byte (4 bits=1 nibble) at the current cursor position into the document (so all data behind the cursor position is shifted 4 Bits to the right)
  • Delete nibble: Deletes half a byte (4 bits=1 nibble) at the current cursor position in the document (so all data behind the cursor position is shifted 4 Bits to the left)
  • Find/Replace: Opens the "Find/Replace" window which allows you to search for hex bytes or text in the active document. You can also replace data using this window. Find and replace processing can be cancelled by pressing the ALT key.
  • Find next: Continue searching for text/data
  • Find all and store: Shows a "Find" dialog where you can select text or data to search for. After clicking the "Find" button in this dialog, all occurences in the active document will be found and stored in the Position list.
  • Convert: Opens the "Convert" dialog that allows you to convert the current selection/document from one charset to another (e.g. from Windows to EBCDIC) or from little endian to big endian and vice versa


View menu

This topic describes the commands in the view menu.
  • Character translation
  • Character translation: Unicode
  • Editor offset format
  • No editing
  • Insert mode
  • Number format
  • Show position relative to EOF
  • Show window bar
  • Synchronize
  • Highlight values

Character translation

With these commands you can switch between different character translations. These translations are used to convert characters from one charset to another when displaying and typing them in the character pane of the editor windows. The "Edit/Find/Replace" command is also affected by the character translation when searching for text.

  • Windows: Do not convert characters (used to edit files containing Ansi text data)
  • Dos 8 bits: Use it to edit files containing text in DOS charset
  • ASCII 7 bits: Use it to edit 7 bits ASCII files
  • Macintosh: For editing files containing Macintosh™ text
  • EBCDIC codepage 38: For files in EBCDIC character set
  • Custom translation: For files in other formats, you can edit the conversion tables using the "Edit custom character translation" dialog

Unicode

In Tiny Hexer it is possible to display unicode text, also basic editing of unicode characters is supported. Switching to unicode mode also affects the "Edit/Find/Replace" command. In unicode mode, no single bytes can be selected, deleted or inserted, only whole unicode characters are editable (each unicode character consists of two bytes).

Note: Unicode mode is disabled on odd sized files (i. e. files whose size is not divisible by two without remainder). As Tiny Hexer can only display 16 bits unicode, the file must consist of whole 16 bits (= 2 bytes) values.

  • Unicode (little endian): Use it to edit little-endian unicode files
  • Unicode (big endian): Use it to edit big-endian unicode files

Editor offset format

These commands allow you to change the format of the offset display (the leftmost part of the editor windows).

  • Hexadecimal: Show cursor offsets in hexadecimal (16 based) notation
  • Decimal: Show cursor offsets in decimal (10 based) notation
  • Octal: Show cursor offsets in octal (8 based) notation
  • None: Don't show cursor offsets
  • Absolute offset: Switch offset display between absolute offset addresses and sector/memory block relative addresses when editing disk sectors/memory blocks

No editing

After switching to "No editing" mode, the affected editor window acts as a file viewer only, the data isn't editable any longer via mouse or keyboard input (but still using plugins and scripts)

Insert mode

Use this menu command to switch the editor from insert to overwrite (overtype) mode

Number format

These commands allow you to change the format of numbers displayed on the status bar.

  • Hexadecimal: Show numbers in hexadecimal (16 based) notation
  • Decimal: Show numbers in decimal (10 based) notation
  • Octal: Show numbers in octal (8 based) notation

Show position relative to EOF

Using this command, you can modify the display of positions on the status bar (relative to start of file or relative to end of file)

Show window bar

Using this command, you can toggle the visibility of the window bar.

Synchronize

This command allows you to synchronize cursor position, view and selection of two editor windows, i. e. if you change the position in one editor, it is automatically changed in the second editor too. This feature is particulary useful when comparing the contents of two files. When switching on synchronization, you can choose the second editor window from a dialog. You can also specify a position offset (e. g. if you select an offset of 400, the cursor in the second editor is set to the position of the first editor + 400). Use the Shift+Tab keys to quickly switch between the two synchronized editors. Synchronization can be turned off by using this command again.

Highlight values

Allows you to enable or disable specific colorization for different data values. These definitions can be changed on the Plugins page of the Global options dialog (Use the Configure button after selecting the "Data highlighter" plugin)


Tools menu

This topic describes the commands in the tools menu. You can add custom tools to this menu by using the "Configure tools" command.
  • Compare
  • Scripts *
  • Configure tools *
  • Alternate data streams *
  • Structure viewer
  • Value editor
  • Status window *
  • Find editor *
  • Position list
  • Calculator
  • Macro
  • Execute script

Compare

The commands in the compare submenu allow you to compare the contents of the current editor data/selection to a file on disk and highlight the differences (showing different bytes in a user defined color in the editor).

  • Compare to file: Select a file on disk and compare its data to the whole data in the active document. After comparison Tiny Hexer will tell you whether data and/or file sizes differ and colorize different bytes in the editor
  • Compare selection to file: Select a file on disk and compare its data to the currently selected block in the active document
  • Compare: Select another editor and compare its data to the whole data in the active document. After comparison Tiny Hexer will tell you whether data and/or file sizes differ, colorize different bytes in the editors and enable synchronization of the editors' views
  • Compare selection: Select another editor and compare its data to the currently selected block in the active document
  • Similarity comparison: Allows to compare two open files using a similarity algorithm. The Similarity comparison dialog is displayed to define the kind and grade of similarity.
  • Previous: Select the previous block of differences. A block is a consecutive range of different bytes.
  • Next: Select the following block of differences
  • Reset: Reset comparison data (switch off)
  • Highlight differences: Switch colorization of different bytes on or off

Scripts*

The scripts submenu lists all Tiny Hexer Scripts located in the <tiny hexer application directory>\scripts path, so you can quickly access utility scripts. Those scripts can additionally have their own icons defined (see scripts\copyhextoclipboard.mps for an example) and then they can be placed on the toolbar using the Customize toolbar dialog.

Configure tools*

Add custom commands to the tools menu by using the "Edit tools" dialog.

Alternate data streams*

Find and manage NTFS alternate data streams by using the "Alternate data streams" dialog.

Structure viewer

Show or hide the structure viewer, a tool that can help understanding the structure of a file by running a Tiny Hexer Script over the file data and displaying the structure in textual format (e.g. in C language "struct" format).

Value editor

Show or hide the value editor, a tool to edit single bits, bytes, words, long words, IEEE floating point numbers and more.

Status window*

Toggles the visibility of the Status window, a tool to quickly see the current data and other information in various data formats.

Find editor*

Toggles the visibility of the Editor finder, a tool to move between Tiny Hexer windows by entering the partial filename.

Position list

Show or hide the position list, a tool to store and display file positions for quick navigation.

Calculator

Show or hide the internal integer calculator.

Macro

The commands in the macro submenu allow you to record sequences of key presses and menu commands as Tiny Hexer scripts for later reuse.

  • Record script: Start recording menu commands and key presses.
  • Stop recording: Stops macro recording and allows you to save the recorded sequence to a file which can be executed later by the Execute script command.
  • Pause: Temporarily interrupts recording of a macro. Use this command again to resume macro recording.

Execute script

Open and execute a Tiny Hexer Script.


Options menu

This topic describes the commands in the options menu.
  • Global settings: Display the "Global settings" dialog to change global options
  • Editor settings: Display the "Editor settings" dialog to change options of editor windows
  • Custom character translation table*: Show the "Edit custom character translation" dialog to create your own character conversion table
  • Load saved settings: Reload a previously saved set of settings
  • Save settings: Save the current settings to disk to reload and use them later
  • Customize toolbar: Display the "Customize toolbar" dialog to change the commands available on the toolbar
  • Language: After selecting a language from the submenu, Tiny Hexer will use that language on the next time it's started


Bookmarks menu

This topic describes the commands in the bookmarks menu.

Tiny Hexer supports two kinds of bookmarks:

  • Per-File-Bookmarks
  • All-Files-Bookmarks

Per-File-Bookmarks are explained in the keyboard section of the editor window topic.

All-Files-Bookmarks apply to all open editor windows. They store the current selection and whether the cursor is located in the hex or character pane. These bookmarks can have descriptive names. Bookmarks appear at the bottom of the bookmarks menu.

When editing disk sectors, a bookmark does not store the current caret position but the absolute position on disk the caret is pointing to.

  • Edit bookmarks: Shows the "Edit bookmarks" dialog, where you can delete, rearrange and modify each existing bookmark
  • Add bookmark: Add a bookmark which stores the current cursor position and selection count. You will be asked to enter a name for the new bookmark


Window menu

This topic describes the commands in the window menu.
  • Cascade: Cascade all visible editor windows
  • Tile horizontally: Tile all visible editor windows horizontally
  • Tile vertically: Tile all visible editor windows vertically


Help menu

This topic describes the commands in the help menu.
  • Index: Opens this help file
  • Version history: Displays the version history of Tiny Hexer
  • Tiny Hexer Script reference: Displays the manual pages about Tiny Hexer Script
  • Look for updates: Searches for a newer version of Tiny Hexer on the web (Windows NT/2000/XP: You need administrative privileges to have access to this command)
  • About: Displays some information about Tiny Hexer


Editor window

This topic briefly explains the editor window.
  • The editor
  • Keyboard support
  • Mouse support

The editor

Each editor consists of different parts (the appearance and existance of some of them may vary depending on Tiny Hexer's settings):

  1. Ruler bar: This is the uppermost part of the editor window, it shows the byte index of each hex or character data. the current cursor column is highlighted (here: "0203")
  2. Offset pane: This part displays the data offset of each row, the current row is highlighted (here: "0x042800")
  3. Hexadecimal field: This field shows the file data byte values in hexadecimal notation. You can insert/overwrite bytes (depending on the active mode), bytes may be arranged in columns of specific widths. Even and odd columns can have different colors.
  4. Character field: This field shows the file data values as characters. You can insert/overwrite characters (depending on the active mode). Characters can be displayed using different conversion tables. In unicode mode each character represents two bytes in the hex field.
  5. Per file bookmark: This "2" sign shows that a per file bookmark (No #2) is set in this row (see the Keyboard section)
  6. Cursor position: A blinking cursor tells you the current position in the file. In INS mode the cursor is a single line, in OVW mode it is a block covering a whole character.
  7. "Fake" cursor: The inactive field also shows you the current cursor position by displaying a dotted frame.
  8. Selected block: The currently selected data is highlighted by inverting the colors.

Keyboard support

The editor has normal keyboard support (like e.g. text editors): Cursor movements, selection using the "Shift" key, scrolling using "Page Up" and "Page Down" and so on.

Some keys have a special meaning:

  • Tab: You can switch between the hexadecimal field and the character field using the "Tab" key (and also Ctrl + T)
  • Shift + Ctrl + 0...9: Using these key combinations you can set one of ten per file bookmarks at the current position. These bookmarks can be defined for each file independently and are persistently stored in the registry.
  • Ctrl + 0...9: Using one of those ten key combinations you can set the cursor to a previously created per file bookmark.

Mouse support

Tiny Hexer supports common mouse operations (selection, cursor positioning). Additionally OLE drag and drop is supported, so you might drag a selected block of data from an editor to another one, from and to other applications supporting OLE drag and drop and even as "Scrap" file to the desktop.

To open a file in a new editor window, just drag it from an Explorer window to the toolbar or status bar of the main window.

You can also use the scrolling wheel of your mouse to change the number of bytes per row by holding down the Ctrl key during "wheeling".


Find/Replace window

In this window you can type hex values or text you want to search for in the active document. If the data has been found, you can replace the current or all occurrences with other data. The window is displayed by the "Edit/Find/Replace" command.

Finding data:

  1. Data edit: Here you can type the hexadecimal byte values or text you want to search for
  2. Text mode: If you want to find textual literals, you can choose the character translation of the text typed in the Data Edit. If the value "(Current mode)" is selected, the current character translation of the actual file is used, e.g. searching for "Text" if the actual file is in EBCDIC mode will search for the EBCDIC representation of the Ansi text "Text"; searching for "Text" in a file in Unicode mode searches for the Unicode representation of the Ansi text "Text"...
  3. Find text: If the box is checked, the text in the data edit is treated as literal text. if the box is unchecked, it is treated as hexadecimal byte values (see also text mode above)
  4. Ignore case: If the box is checked, the search is case insensitive, so uppercase and lowercase representations of the values in the data edit will be found
  5. Use wildcard: If this box is checked, the value in the wildcard edit is used as "any byte" value (works like the dos file wildcard "?")
  6. Wildcard edit: Here you can type a value in either hexadecimal byte form (2 hex digits, e.g. FF to use the character with the ascii value 255) or as a character (prefixed by a single quote, e.g. '? to use the question mark).
    This value is used as a wildcard while searching. In the first example the values "00 02 00 00", "00 02 01 00" ... "00 02 FF 00" would be found
  7. Regular expression: If the box is checked, Tiny Hexer performs a pattern search based on regular expressions in the data (like the un*x grep utility). In this case, the pattern cannot be typed in hex ("00 02 FF 00") notation; also the wildcard edit is disabled as regular expression based searches are much more flexible than using just a single wildcard
  8. Find: Start/continue searching
  9. Close: Close this window
  10. Help: Show this help topic
  11. Replace: This button is enabled when the data has been found. By clicking this button the replace controls are made available.

Replacing data:

  1. Replace data edit: Here you can type the hexadecimal byte values or text you want to use as replacement data. Leave the field empty to remove the data searched for from the active document
  2. Text mode: If you want to replace with textual literals, you can choose the character translation of the text typed in the replace data edit. If the value "(Current mode)" is selected, the current character translation of the actual file is used, e.g. replacing with "Text" if the actual file is in EBCDIC mode will replace with the EBCDIC representation of the Ansi text "Text"; replacing with "Text" in a file in Unicode mode replaces with the Unicode representation of the Ansi text "Text" and so on
  3. Is text: If the box is checked, the text in the replace data edit is treated as literal text. if the box is unchecked, it is treated as hexadecimal byte values (see also text mode above)
  4. Replace: Replace the current occurrence of the values in find data edit with the values from the replace data edit
  5. Replace all: Replace all occurrences of the values in find data edit with the values from replace data edit


Structure viewer

This viewer is used to display the contents of a file in a structured manner to make it easier to understand the data. The window is shown by checking the "Tools/Structure viewer" command.

The viewer uses scripts written in Tiny Hexer Script to display the data structures. Sample scripts for .zip, .exe and .bmp files and NTFS, FAT12 and FAT16 boot structures are provided. You can write your own scripts for different data formats. After storing them in the <application directory>\scripts\Structure Viewer directory they can be used with the structure viewer by clicking the Open structure script button and loading the script.

Scripts to be executed within the structure viewer must contain the directive line OPTION TARGET, STRUCTUREVIEWER.

As of version 1.6 of Tiny Hexer, the structure viewer can also be used to display non-preformatted HTML documents.

  1. Clear: Unload the currently loaded script and clear the structure browser
  2. Open structure script: Load a structure script into the viewer and try to display the data structures of the current hex editor window's file in the structure browser
  3. Update: Rescan the active editor window's file data and display its structures in the structure browser
  4. Stop: Scanning data might take some time. While structure scanning is executing, you can stop this process by clicking this button
  5. Save browser contents: Save the structure browser contents either in text or HTML format
  6. Print browser contents: Print the structure browser contents after displaying a printing options dialog
  7. Help: Show this help topic
  8. Start at position 0: If this is checked, the data structures are read from the first byte of the current file. If unchecked, structures a read from the current cursor position.
  9. Script Selector: Select a structure script, load it into the viewer and try to display the data structures of the current hex editor window's file in the structure browser
  10. Structure browser: This browser actually displays the data structures
  11. Hyperlinks: Underlined texts mark hyperlinks. Those links are useful to locate specific positions and select a specific block in the editor window. Links are created by the scripts (by using tagged variables)


Value editor

Using the value editor you can edit hex data in different formats (like byte, char, LONGWORD, IEEE Float...). The window is shown by checking the "Tools/Value editor" command.

The Value Editor displays the data at the cursor position in the active editor window in the selected data format. The data range currently being displayed and edited in the value editor is highlighted using a different color in the hex editor.

  1. Type selector: Here you can choose the data type to display/edit
  2. Big endian: By checking this box you tell the value editor to read/store the data in big endian format (this data format is used e.g. on some Motorola processors). If the box is unchecked, low endian format is used (e.g. Intel)
  3. Value: The actual data in the specified format. You can change the value by overwriting the value. If the "char" data type is used, you can either set the value in numerical notation or as a character. this character value must be put in quotes (e.g. "A").

    Note: To quickly edit multiple values, you can use the cursor keys to apply changes you made and navigate to a different position:

    • CURSOR UP: One Value Left
    • CURSOR DOWN: One Value Right
    • SHIFT + CURSOR UP: One Byte Left
    • SHIFT + CURSOR DOWN: One Byte Right

    You can also use mathematical expressions in Tiny Hexer Script format in this edit box. Prefix the expression by an equal sign ("="), e.g. "=PI//2".
    There is an item "Copy as hex" in this edit box' popup menu which allows you to copy the current value in hexadecimal format to the clipboard.

  4. Radix: If an integer data format is chosen, you can change this value to display/edit the value in octal (8), decimal (10) or hexadecimal (16) notation
  5. Bits: This panel shows the value as single bits, bytes are separated by a vertical line. You can change a single bit by clicking the corresponding box. a filled box means "1", an empty box means "0". By right clicking the bits panel, a popup menu is shown that allows you to switch or clear the current or all bytes of the value
  6. One value left: The cursor in the editor window is set to current position - sizeof(selected data type), so if the selected data type is word, the cursor is set two bytes to the left because a 16 bits word consists of two bytes. After moving the cursor, the new data block is displayed in the value editor
  7. One byte left: The cursor is set to current position - 1
  8. One byte right: The cursor is set to current position + 1
  9. One value right: The cursor is set to current position + sizeof(selected data type)
  10. Find data: On clicking this button, the hexadecimal representation of the current value is displayed in a "Find" dialog to simplify searching for e.g. specific floating point values
  11. Help: Show this help topic
  12. Apply changes: After you made manual changes to the data (by modifying the data in the value edit box or changing some bit on the bits panel), you can write back the changed data to the editor by clicking this button


Position list

This list is used to store different file positions to quickly navigate in a document. The window is shown when checking the "Tools/Position list" command.

In this list window you can collect different file positions and selections. The "Edit/Store in position list" and "Edit/Find all and store" commands are used to add entries to this list.
You can save position lists to files, print them and export them to text files. Each list can have a description that is stored and printed.
The list has a context menu with additional commands.

  1. Load from file: Load a previously saved list from disk
  2. Save to file: Save the contents of the list to either a list file that can be reloaded or a text file
  3. Print list: Print the current list
  4. Description: In this field you can change the current list's description
  5. The list: Each entry in this list stores a cursor position/selection. The display format depends on the number format setting. When doublecklicking an entry or pressing the RETURN key, the cursor in the active document is set to this position. The number in parenthesis shows the amount of data to be selected
  6. Delete: This context menu entry allows you to remove the selected entries from the list
  7. Shift: You will be asked to enter an offset value (+/-), then all selected entries' position will be shifted by this value
  8. Copy: Copy the current selection to the clipboard
  9. Select all: Select all entries in the list
  10. Entry count: This value tells you the number of entries in the list


Calculator tool

Use the "Tools/Calculator" command to toggle the visibility of the calculator tool.

  • Number display: shows the current value
  • M0..M7, MC, MR, MS, M+: used to manage the eight memory cells
  • Hex, Dec, Oct, Bin: change the number radix
  • Quad word, Long word, Word, Byte: change the data value type
  • Back, CE, C: clear last digit, whole current number, whole calcualtion buffer
  • (, ): create/finish a sub expression
  • +/-: toggle sign
  • NOT: one's complement
  • +, -, *, /, MOD, <<, >>, AND, OR, XOR: operators
  • =: finish calculation and show the result


Status window*

This tool window is toggled by the command "Tools/Status window". It displays information about the current file and data in various formats.

Do a right click on the status window to show a popup menu containing some additional commands.

  1. Status window: Shows information about the current file and data in various formats
  2. Big Endian: Toggles between little and big endian data format display of the selected item
  3. Copy All: Copy the current view in textual form to the clipboard
  4. Copy current value: Copy the value of the selected item to the clipboard
  5. Manage infos: Display the Manage infos dialog to select the items to be shown in the status window
  6. Number format: Toggle the number format of the selected item:

    • Hexadecimal: Display the value in hexadecimal notation
    • Decimal: Display the value in decimal notation
    • Octal: Display the value in octal notation
    • Auto: Use Tiny Hexer's default number format


Editor finder*

Visibility of this tool window is toggled by the command "Tools/Find editor". The tool is used to find open editor windows by partial filename.

  1. Partial caption: Enter a part of the name of the file (open in Tiny Hexer) that you want to activate and press the ENTER key
  2. Matching windows: All open document windows matching the name criterion are displayed in this list. Doubleclick a line to activate that document


Customize toolbar dialog

Using this dialog you can select the command buttons which are shown on the toolbar. This dialog can be accessed by doubleclicking the toolbar or using the "Tools/Customize toolbar" command.

  1. Available buttons: This list contains all available commands that can be added to the "Current buttons" list (and thus to the toolbar). By doubleclicking an item (or using the "Add button" command (3)), this item is moved from this list to the "Current buttons" list; it is inserted at the current position. The last entry is the "separator" item, it is used to separate blocks of command buttons and can be added to the toolbar multiple times
  2. Current buttons: This list displays all commands that are shown on the toolbar. By doubleclicking an item (or using the "Remove button" command (4)), an item can be moved from this list to the "Available buttons" list to remove this command from the toolbar. The uppermost list entry corresponds to the leftmost toolbar button
  3. Add button: Move the selected command from the left list to the right list to show this command on the toolbar
  4. Remove button: Move the seleted command from the right list to the left one to remove that command from the toolbar
  5. Move up: Move the selected command in the right list one position up (and so one button to the left on the toolbar)
  6. Move down: Move the selected command in the right list one position down (and so one button to the right on the toolbar)
  7. Reset: Reset the "Current buttons" list to factory defaults
  8. Help: Show this help topic
  9. OK: Accept the changes and rebuild the toolbar command buttons
  10. Cancel: Close the dialog without accepting the changes


Edit bookmarks dialog

In this dialog you can change and delete bookmarks. This dialog is displayed by issuing the "Bookmarks/Edit bookmarks" command.

  1. Bookmarks list: This list shows all existing All-Files bookmarks. By selecting an item you can modify its properties using the other controls
  2. Move up: Move the selected bookmark one position up in the "Bookmarks list" and also in the bookmarks menu
  3. Move down: Move the selected bookmark one position down in the "Bookmarks list" and also in the bookmarks menu
  4. Delete bookmark: Click this button to delete the selected bookmark
  5. Name: Here you can change the name of the selected bookmark which is displayed in the Bookmarks menu
  6. Position: Displays the position that the bookmark represents. You may change it in hexadecimal (prefixed by "0x") or decimal notation
  7. Hex field: If the box is checked the cursor is set to the hex field of the editor when selecting the bookmark from the menu. If the box is unchecked, the cursor is set to the character field
  8. Count: Displays the selection count that the bookmark represents. You may change it in hexadecimal (prefixed by "0x") or decimal notation
  9. OK: Accept the changes and rebuild the bookmarks menu
  10. Cancel: Close the dialog without accepting the changes
  11. Help: Show this help topic


Set selection dialog

Use this dialog if you want to choose starting and ending position of a block to be selected numerically . This dialog is opened by the command "Edit/Select".

  1. Selection start: Type the starting position of the new selection in hexadecimal (prefixed by "0x") or decimal notation. You can also use a position relative to the current cursor position or file end: When prefixing the number by a minus ("-") or plus ("+") sign, the new selection start is relative to the current cursor position, when prefixing by a greater than (">") sign, the new selection start is relative to the file's end
  2. Selection end: Type the end position of the new selection in hexadecimal (prefixed by "0x") or decimal notation. You can also use a position relative to the new selection start or file end: When prefixing the number by a minus ("-") or plus ("+") sign, the new selection end is relative to the selection start typed above, when prefixing by a greater than (">") sign, the new selection end position is relative to the file's end
  3. OK: Use the typed values to select a block in the active editor window
  4. Cancel: Close the dialog without changing the selection
  5. Help: Show this help topic


Convert dialog

Using this dialog you can convert a file or a selected block from one character translation to another one or from little endian to big endian and vice versa. The dialog is displayed by using the "Edit/Convert" command.

  1. Convert characters: Select this radio button to convert data from one character translation to another one
  2. Source: Select the source character translation
  3. Target: Select the target character translation

  4. Little endian <-> Big endian: Select this radio button to convert data from Little/Big endian to Big/Little endian, respectively
  5. Data type: Here you can change the type of the data to be converted from one endian type to the other (WORD (16 Bits), LONGWORD (32 Bits) or SIGQWORD (64 Bits))

  6. Selection only: Convert the currently selected block only

  7. OK: Convert the file or selected block
  8. Cancel: Close the dialog without changing data
  9. Help: Show this help topic


Open drive/partition dialog

Using this dialog you can open a hard disk, a floppy disk or a CD Rom sector by sector in an hex editor window. This dialog is opened when issuing the "File/Disk/Open drive" command. (Windows NT/2000/XP only, you might need administrative privileges to gain direct access to drives)

  1. Drive and partition list: This list shows the drives and partitions that can be opened in an hex editor window. Hard drives are named "\\.\PHYSICALDRIVE<number>", where number is the system index of the physical drive (drive numbers are zero-based, partition numbers are one-based). CD Roms are called "\\.\CDROM<number>". CD Roms, floppy disks and logical hard drive volumes are displayed using the drive letter (hard drive volumes also show the actual drive and partition number). CD Roms and floppy disks are not shown if no medium is inserted.

    The second column displays the amount of sectors on the medium, the third row shows the sector size.
  2. Load <value> sectors at a time: This control allows you to display a consecutive sequence of disk sectors at once in the hex editor window.
  3. First sector: Here you can set the index of the first sector to be read into the editor window
  4. Set as default: Set the currently selected amount of sectors as default value for this dialog
  5. Readonly: If this box is checked, disk data is opened in read only mode and cannot be edited
  6. OK: Open the drive or partition selected in the list above in a new editor window
  7. Cancel: Close the dialog without opening a drive/partition
  8. Help: Show this help topic
  9. Reload: Rebuild the list of available drives/partitions and removeable media


Open disk image/large file dialog

Using this dialog you can edit a disk image file or other files bigger than 2 GB sector by sector in an hex editor window. This dialog is opened when issuing the "File/Disk/Open disk image or large file as drive" command.

  1. Image/File to open: Here you can select the disk/CD/DVD image or large file to be edited. Click the folder button at the right to display a file selection dialog where you can choose the file
  2. File size: Here the size of the chosen file is displayed in byte and sector units
  3. Sector size: Select the size of a sector in the disk image. Hard disk and floppy disk images usually have a sector size of 512 Bytes, CD and DVD images have a sector size of 2048 Bytes. Normal files have no specific sector size, so you can select a sector size of you choice, e.g. 4096 Bytes. You may also type a sector size manually.
  4. First sector: Here you can set the index of the first sector to be read into the editor window
  5. Load <value> sectors at a time: This control allows you to display a consecutive sequence of disk image sectors at once in the hex editor window.
  6. Readonly: If this box is checked, disk data is opened in read only mode and cannot be edited
  7. OK: Open the selected disk image or large file in a new editor window
  8. Cancel: Close the dialog without opening a disk image
  9. Help: Show this help topic


Read process memory dialog

This dialog allows you to select a memory block in another process to be opened in Tiny Hexer. This dialog is opened when executing the "File/Process/Read process memory" command. (On Windows NT/2000/XP, you might need administrative privileges to read the memory of other processes)

  1. Reload process list: The process list (2) gets updated.
  2. Process list: Displays all available processes currently running. Click on an item to show its memory map in the memory blocks list (3).
  3. Memory blocks list: Displays the memory blocks of the selected process. Memory blocks which are not accessible (PAGE_NOACCESS, MEM_FREE) are hidden from the list. Yellow items are larger in size than the chosen limit (6) and thus are not completely loaded into the preview editor (4) and searched (7)
  4. Preview: Displays the contents of the currently selected memory block. If the data cannot be read, the preview editor is displayed using a red color.
  5. Unicode: If this box is checked, the contents of the currently selected memory block are treated as 16 bit unicode text (e.g. environment blocks on NT). This settings also affects the search (7) for text data.
  6. Limit to <value> MB: If the preview of large memory blocks leads the system to start swapping or stop responding, you might decrease this value. Only the part of the memory block up to the limit is loaded into the preview editor. This also affects searching (7).
  7. Search: Show a "Find" dialog to search for data or text in the selected (or all) process's memory.
  8. Help: Show this help topic.
  9. Open: Load the selected memory block into an Tiny Hexer editor window.
  10. Use limit: If this box is checked, only the part of the memory block up to the limit value (6) is opened in Tiny Hexer's main window.
  11. Cancel: Close this dialog without opening a memory block.


Write process memory dialog

This dialog allows you to write back a modified memory block to another process. This dialog is shown when executing the "File/Process/Write process memory" command. (On Windows NT/2000/XP, you might need administrative privileges to write to the memory of other processes. Depending on the properties of the selected memory block, writing might not be possible at all.)

  1. Process: Shows the process that owns the edited memory block.
  2. Base adress: Displays the base address of the modified memory block. This address can be changed to write to a different address.
  3. Selected bytes only: Allows you to write only the data currently selected in the editor.
  4. OK: Write the memory block.
  5. Cancel: Close this dialog without writing the memory block.
  6. Help: Show this help topic.


Print preview window

This windows show a print preview of the active editor document. You can also start the actual printing here. The window is shown by using the "File/Print" command.

  1. Page selector: Select the page you want to show in the preview pane
  2. Print range: Select the data range to print:

    • All pages: Print the whole document
    • Current page: Print the page selected in the Page Selector
    • Selection: Print the current editor selection only
    • Editor view: Print the data range actually visible in the editor

  3. Margins: Enter the top, left, right and bottom print margin in millimeters
  4. Font: Click this button to choose the font used for printing
  5. Print colors: Check this box to use the editor's colors for printing
  6. Use background color: Check this box to paint the paper's background using the editor's background color
  7. Highlight selection: Check this box to mark the block currently selected in the editor using either a bold font (if not using background colors) or inverted colors
  8. Print ruler: Check this box to print a ruler at the top of each page
  9. Page header: The contents of this field are printed at the top of each page. The page header consists of three parts (left, centered and right) which are separated by pipe characters ("|") in this edit box. There are a few macros available here:

    • %f: Print the filename of the printed document (without path)
    • %F: Print the filename of the printed document (including path)
    • %p: Print the currently printed page's number
    • %P: Print the number of pages
    • %t: Print the current time
    • %d: Print the current date
    • %>: Print the long name of the active document's character translation (like "Windows", "DOS 8 bits", "Unicode big endian"...)
    • %<: Print the short name of the active document's character translation (like "WIN", "DOS", "UCBE"...)

  10. Page footer: The contents of this field are printed at the bottom of each page. The page header macros can also be used here. The footer also consists of a left, a centered and a right part
  11. Preview pane: This part displays a preview of the selected page
  12. Zoom button: Use this button to change the preview's size
  13. Help button: Show this help topic
  14. Print setup button: Displays Windows' printer setup dialog
  15. Print button: Start printing and close this window
  16. Close button: Close this window without printing


File import*

This dialog allows you to select the data format of a file you want to import. The dialog is opened by using the "File/Import" submenu commands.

Files in specific formats can be imported by executing one of the Tiny Hexer Scripts in the <application directory>\scripts\import directory. You can place your own import scripts here to add import capabilities for different file formats to Tiny Hexer. These scripts need a special format1 to be recognized by this dialog.

  1. Select a format: Choose one of the data formats available for import
  2. Import: Start data import
  3. Cancel: Close the dialog without importing the selected file
  4. Help: Show this help topic

1) Import script file format:

The directives TITLE (= description of the import script) and OPT2 (= default file extensions of files that should be imported using the script) are used to tell this dialog which settings to use.

When the import dialog is shown it checks whether the file extension of the file to be imported is registered by one of the import scripts. If yes, this script is automatically selected in the "Select a format" list.

Additionally import scripts must contain the directive line OPTION TARGET, IMPORT.


File export*

This dialog allows you to select the data format of a file you want to export. The dialog is opened by using the "File/Export" command.

Open files can be exported to different data formats by executing one of the Tiny Hexer Scripts in the <application directory>\scripts\export directory. You can place your own export scripts here to add export capabilities for different file formats to Tiny Hexer. These scripts need a special format1 to be recognized by this dialog.

  1. Select a format: Choose one of the data formats available for export
  2. Export to clipboard: If this box is checked, the file is exported to the clipboard rather than the disk
  3. Selection only: Export the currently selected block only
  4. Export: Start file export
  5. Cancel: Close the dialog without exporting data to a file or the clipboard
  6. Help: Show this help topic

1) Export script file format:

The directives TITLE (= description of the export script), OPT1 (= filter used in the save dialog) and OPT2 (= default file extension of files being exported using the script) are used to tell this dialog the settings to use.

Additionally export scripts must contain the directive line OPTION TARGET, EXPORT.


Edit tools dialog*

This dialog allows you to modify the list of external tools on the Tools menu. It can be accessed by using the "Tools/Configure tools" command.

  1. Tools list: All external tools currently displayed on the tools menu can be modified by doublecklicking the corresponding entry on this list
  2. Move up: The selected tool entry is moved up one row in the list (and thus on the Tools menu)
  3. Move down: The selected tool entry is moved down one row in the list (and thus on the Tools menu)
  4. New: Add a new entry to the tools list and modify its properties
  5. Delete: Remove the selected entry from the list (and the Tools menu)
  6. Help: Show this help topic
  7. OK: Accept the changes and rebuild the Tools menu
  8. Cancel: Close the dialog without accepting the changes


Tool properties

Tool properties dialog*

This dialog allows you to modify the properties of each external tool on the Tools menu. It is used by the "Edit tools" dialog.

  1. Caption: A description of the tool as it is displayed on the Tools menu
  2. Program: The filename of the program. The program can either be an executable file or a Tiny Hexer Script. A file selection dialog is shown so you can choose the program/script when clicking the "..." button
  3. Directory: The working directory used when executing the program
  4. Arguments: Command line arguments that will be passed to the program/script. A Tiny Hexer Script can access these arguments using PARAM_COUNT and PARAMS().

    Some macros can be used to control tool execution:

    $(FILE): This macro is replaced by the filename of the active document on tool execution

    $(INPUT): You will be prompted to type an argument. This text will replace the macro on tool execution

    $(POSITION): This macro is replaced by the position of the cursor in the active document on tool execution

    $(SAVE): Save the active document before executing the tool. The macro is removed from the parameters passed to the tool

    $(SCRIPT): This macro is removed from the list of arguments. It tells Tiny Hexer that the tool is a Tiny Hexer Script rather than an executable program

    $(SELCOUNT): This macro is replaced by the amount of selected data in the active document on tool execution

    $(SELSTART): This macro is replaced by the start of the selected block in the active document on tool execution

    $(SIZE): This macro is replaced by the size of the active file on tool execution

    $(WAIT): : This macro is removed from the list of arguments. It tells Tiny Hexer that program execution should wait until the tool has finished

  5. Icon: Specify an icon to be displayed in the menu and toolbar for this item. A "pick icon" dialog is shown so you can select an icon when clicking the "..." button
  6. OK: Accept the changes and close this dialog
  7. Cancel: Close the dialog without accepting the changes
  8. Help: Show this help topic


File statistics dialog*

This dialog shows you some statistics for the current file or selection. It can be displayed using the "File/Statistics" command.

  1. Byte usage: This list shows you the occurence of each byte value in the data. Click on a list column to change the sort order.
  2. Arithmetic mean: Displays the arithmetic mean of all data values, depending on the selected data type (5).
  3. Geometric mean: Displays the geometric mean of all data values, depending on the selected data type (5).
  4. Standard deviation: Displays the standard deviation of all data values, depending on the selected data type (5).
  5. Data type: Choose the type of the data to calculate the statistics and display the graph.
  6. Big Endian: Tells Tiny Hexer that the data is stored in big endian format.
  7. Scale to range of used values: Scale the graph axes to display just the range of actual data values in the current file.
  8. Graph: Graphical representation of the data.
  9. Close: Close this window.
  10. Export: After selecting a filename, the current statistics are saved in RTF format.
  11. Help: Show this help topic.


File properties dialog*

This dialog allows you to display and modify a file's attributes. The dialog can be displayed using the "File/Properties" command.

  1. File name: This is the file's name on disk. You can modify this value to rename the file.
  2. File type/Location/Short name: Displays the file type, the path and the 8.3 name of the file (depending on the operating system).
  3. Editor size: The size of the file in the editor. You can modify the value to shrink or grow the file in the editor.
  4. File size: The size of the file on disk. You can modify the value to shrink or grow the file on disk.
  5. Created: Creation timestamp of the file on disk. You can modify the value to change this timestamp on disk.
  6. Modified: "Last write" timestamp of the file on disk. You can modify the value to change this timestamp on disk.
  7. Last access: "Last access" timestamp of the file on disk. You can modify the value to change this timestamp on disk.
  8. File attributes: Displays various file system attributes of the selected file. You can change them by clicking the check boxes. As some file attributes cannot be modified using the SetFileAttributes() API, those are disabled.
  9. Help: Show this help topic.
  10. OK: Close this window after trying to apply the modifications (if any).
  11. Cancel (/ Close): Close this window without applying the current changes. Modifications applied using the "Apply" button (12) are not undone!
  12. Apply: Try to apply the modifications. After using this button, the dialog's values are refreshed from the file system.


Global options dialog

This dialog allows you to modify the global settings of Tiny Hexer. It can be accessed from the "Options/Global settings" menu.
  • General settings (page 1)
  • General settings (page 2)
  • Scripts
  • Keyboard mapping
  • Plugins

General settings (page 1)

  • Support OLE drag and drop: If this box is checked, you can use drag and drop to copy or move data from Tiny Hexer to other applications and vice versa. You can also drag data from an editor to a folder in Explorer to create so called "Scrap Files"
  • Maximize new editor windows: If this box is checked, Tiny Hexer creates new editor windows in maximized state
  • Initial INS mode on file opening: If this box is checked (default), documents are opened in INS mode (i.e. data is inserted when typing values). If the box is not checked, documents are opened in OVW mode (on typing values the current data is overwritten). New (empty) editor windows are always created in "insert mode"
  • Show hex chars in lower case: If this box is checked, hexadecimal numbers are displayed using lower case letters in the editor's hexadecimal field, otherwise upper case letters are used
  • Use mouse wheel for zooming: If this box is checked, you can change the number of bytes displayed in each row using the mouse wheel and pressing the CTRL key
  • Open a new editor at startup: If this box is checked, Tiny Hexer creates an empty editor window if it's run without command line parameters
  • Explorer integration: If this box is checked, you can open any file from Explorer's context menu ("Open with Tiny Hexer"). (On Windows NT/2000/XP you need administrative privileges to change that option)
  • Tile windows vertically when synchronizing views: If this box is checked, the windows of two files being synchronized via View/Synchronize (or compared via Tools/Compare/...) are automatically tiled vertically
  • Persistent custom editor properties: If this box is checked, custom editor properties are persistently stored in the registry
  • Allow invalid (ADS) names in Open/Save dlgs: If this box is checked, you can use Alternate Data Stream filenames (containing a colon character ":" to separate the file name from the stream name) in open and save file dialogs.

General settings (page 2)

Backups

  • Create backups: If this box is checked, Tiny Hexer creates backups of modified files before they are rewritten to disk
  • Backup file extension: Tells Tiny Hexer what file extension it should add to file being backuped

Clipboard

  • Text is in hex text format: If this box is checked, text data pasted from clipboard will not be inserted as is, but read as Hex Text ("00 01 02 03...")
  • Preserve contents on exit: If this box is checked and Tiny Hexer has put some data to the clipboard, the clipboard data will be available after Tiny Hexer terminated. Otherwise, Tiny Hexer clipboard data is removed on exit

Shortcuts

Here you can define the keyboard shortcuts of Tiny Hexer's menu commands. Select a command from the commands list, focus the hotkey box and press the key combination you want to use to execute the command.

Path for temporary files

Here you can select a directory which is used by Tiny Hexer to store temporary files. By default, the user's (or system's) %temp% directory is used.

White space replacement

The character that is displayed in the editor's character field when displaying data in the value range 0..31

Maximum size of undo buffer

Tells Tiny Hexer how much memory it should provide for undo storage. The higher this value, the more modification steps are undoable. If this limit gets exceeded, the oldest undo record is removed from memory, so the corresponding modification can no longer be undone. If set to 0, there is no limit (except virtual memory)

Scripts

  • Startup script: Here you can choose a Tiny Hexer Script which automatically gets executed when Tiny Hexer is started.
  • Exit script: Here you can choose a Tiny Hexer Script which automatically gets executed when Tiny Hexer is terminated.

You might try the startup.mps/stop.mps script couple located in the scripts/start-stop directory. These scripts can re-open the files which were opened in the previous Tiny Hexer session. Even the selections are remembered.

Keyboard mapping

In Tiny Hexer it is possible to reconfigure the keyboard when typing hexadecimal values into an editor's hexadecimal field and characters into its character field independently. E.g. in some keyboard layouts typing numbers needs the usage of additional control keys, so keyboard reconfiguration could be used to map the key "q" to the number "0" to simplify number typing in the hexadecimal field (where the "q" character is not used).

  1. Mappings list: Select a key mapping to change its properties
  2. Add: Add a new key mapping
  3. Delete: Remove the selected key mapping
  4. Clear: Clear the whole list
  5. Character typed: The source key that you want to remap to a different one
  6. Maps to: The target key press sent to the editor instead of the source key

Plugins

As of version 1.5 of Tiny Hexer, plugins can be used to add extended functionality. Plugins are external libraries with an .thp extension located in the program directory of Tiny Hexer.

Some of the plugins are described in this help file, they are marked with a green asterisk (*)

  • Available plugins: Here all plugins found in Tiny Hexer's program directory are listed. You can enable/disable each plugin by changing the state of the checkbox to the left of the plugin's description
  • Select all: Enables all listed plugins
  • Deselect all: Disables all listed plugins
  • Configure: Displays the selected plugin's configuration dialog (not all plugins have such a dialog and only plugins already loaded can be configured)


Editor options dialog

This dialog allows you to modify editor related settings of Tiny Hexer. It can be accessed from the "Options/Editor settings" menu.
  • Row size: Select how many bytes are displayed in each editor's row
  • Column size: Select how many bytes are displayed per column
  • Block size: Select how many bytes are displayed per block
  • Show gridlines: If this box is checked, lines are drawn between rows and columns in the editor
  • Gutter has 3D borders: Display a 3D border frame around the editor's internal borders
  • Fixed file size: If this box is checked, you cannot change the size of the file being edited. This option cannot be changed when editing disk sectors or memory blocks
  • Show ruler bar: Display a ruler bar on top of the editor
  • Swap half bytes: If this box is checked, nybble order is reverted in the editor's hexadecimal field (so e.g. the byte "01" will be displayed as "10")
  • Font: Change the font used in the editor
  • Colors: Select an item from the list and change its text and background color

Default checkbox: Mark this check box to apply the settings to all future editor windows. If this box is unchecked, the settings apply to the active editor window only.

Apply to all checkbox: Mark this check box to apply the settings to all currently opened editor windows.


Edit custom character translation

Edit custom character translation dialog*

In this dialog you can create and modify the custom character translation tables (e.g. to work with files in special EBCDIC formats). This dialog can be accessed by using the "Options/Custom character translation table" command.

Each custom character table consists of two parts: Conversion from Windows to custom charset and from custom to Windows charset. The first one is used to convert characters typed in the character field of an editor window, the second one is used to convert characters from the file data to the windows charset when displaying them in the editor's character field.

  1. Load table: Load a character translation table from disk
  2. Save table: Save the modified table to a file on disk
  3. Generate second table: If the modified table ("From Windows codepage" or "To Windows codepage") is reversible, the other table can be automatically generated using this button. Reversible here means that each source character maps to exactly one target character
  4. Reset: Reset the table to 1:1 character mapping
  5. Copy from: Load one of the predefined tables (Macintosh, EBCDIC CP38 or OEM (DOS)) to use it as starting point to create your own table
  6. From Windows codepage: Click this tabulator to edit the table being used to map Windows characters to custom charset characters
  7. To Windows codepage: Click this tabulator to edit the table being used to map custom charset characters to Windows characters
  8. Table editor: Using the editor you can modify the character mappings. E. g. if source character 0x5B should map to target character 0x4A in your customized character translation table, set the cursor to position 0x5B and type the value 4A in the editor's hexadecimal field
  9. Current character mapping: Displays the hexadecimal code of the source and the target character, separated by a colon
  10. Help: Show this help topic
  11. OK: Store the modified character translation table and close the dialog. After this you can use the newly created table by switching to "Custom translation" in the "View/Character translation" menu
  12. Cancel: Close the dialog without storing the table


Insert partial file dialog

This dialog is displayed by the command "File/Insert partial file". It is used to specify the properties of the file part to be inserted.

  1. Data start: Type the starting position of the file's partial data to be inserted in hexadecimal (prefixed by "0x") or decimal notation. You can also use a position relative to the file's end: When prefixing the number by a greater than (">") sign, the data start is relative to the file's end
  2. Data end: Type the end position of the file's partial data to be inserted in hexadecimal (prefixed by "0x") or decimal notation. You can also use an absolute number of bytes to be inserted (prefix plus sign ("+")) or an end position relative to the file's end (prefix greater than sign (">"))
  3. OK: Use the values entered and insert the file's data in the active editor
  4. Cancel: Close the dialog without inserting data
  5. Help: Show this help topic


Paste over file dialog

This dialog is displayed by the command "File/Paste over file". It is used to specify the properties of the data to be written over a file.

  1. File to write to: The file whose data is about to be overwritten
  2. Position: Type the position in the file where to store the data in hexadecimal (prefixed by "0x") or decimal notation. You can also use a position relative to the file's end (prefix greater than sign (">"))
  3. Selection only: Just paste the currently selected data bytes over the file, not the editor's whole data
  4. OK: Use the values entered and paste the data over the selected file
  5. Cancel: Close the dialog without overwriting the file's data
  6. Help: Show this help topic


Alternate data streams dialog*

This dialog allows you to manage alternate data streams (ADS) on NTFS file systems. It can be accessed by using the "Tools/Alternate data streams" command.

  1. Directory combo box: This combo shows the root directory where to search for files containing alternate data streams
  2. Select directory: Select the root directory for ads search
  3. Recurse subdirectories: Search for ads in the selected directory and all its sub directories
  4. Find streams: Start searching for alternate data streams. Press the ESC key to stop a search<</li>
  5. ADS list: Lists the found alternate data streams
  6. Edit stream data: Open the selected stream in Tiny Hexer to edit its contents
  7. Delete: Remove the selected alternate data stream from its associated file or directory
  8. Save current file to this stream: Save the contents of Tiny Hexer's active document to the selected stream
  9. Close: Close the dialog
  10. Help: Show this help topic


Similarity comparison dialog

This dialog is displayed by the command "Tools/Compare/Similarity comparison". It is used to specify the grade and kind of similarity for file comparison.

  1. Data type: Select the data type to be used when comparing the open files
  2. Max. deviation: This value is used to decide whether the data from the two files being compared is to be treated similar or different. Only differences above this value are seen as "different"
  3. Selection only: Just use the current selection for comparison, not the whole file
  4. Big Endian: Tells Tiny Hexer whether to use little or big endian data format for comparison
  5. OK: Start file comparison using these settings
  6. Cancel: Close the dialog without comparing the files
  7. Help: Show this help topic


New file properties dialog

This dialog is displayed by the command "File/New (Advanced)". It is used to specify the properties of the new file to be created.

  1. File size: Type the data size of the file to be created
  2. Fill byte: Type the value of the byte that is used to create the new file
  3. Character mode: Select the initial character set to use when editing the newly created file
  4. Fixed file size: The data size cannot be changed after creation
  5. Swap half bytes: Swap low and high nybble when displaying and editing data bytes
  6. Create: Do create the new file with the specified properties
  7. Cancel: Dismiss this window and do not create a new file
  8. Help: Show this help topic


Command line parameters

Here the command line parameters supported by Tiny Hexer are listed.

The following command line parameters are supported:

  1. filename: File filename is opened in Tiny Hexer.
  2. /n: Normally, Tiny Hexer opens an untitled editor window if no files to open are given on the command line. If this parameter is present, no such untitled editor window will be opened (deprecated, use the "Open a new editor at startup" setting in the "Global options" dialog).
  3. /newinst: Allows to run multiple instances of Tiny Hexer.
  4. /noed: Forces all files to be opened in "No editing" mode during this Tiny Hexer session. This parameter should be specified as the first one.
  5. /p filename: File filename is opened and printed. If no additional arguments are given, Tiny Hexer terminates after printing.
  6. /s filename: The Tiny Hexer Script file filename is opened and executed.
  7. /sp argument: modifies the /s parameter, adds a parameter argument to the commandline of the script to be executed (see PARAMS() function). Note: /sp arguments must precede the /s parameter! (E.g. mpth.exe /sp c:\boot.ini /s scripts\checksums.mps)


Tiny Hexer Script

In this topic you will find an introduction to the Tiny Hexer Script language.
  • Overview
  • Data types
  • Variables
  • Expressions
  • Operators
  • Directives
  • Commands
  • Functions
  • Localizing scripts
  • Graphical User interfaces

Overview

Tiny Hexer Script is an interpreted programming language to add scripting capabilities to Tiny Hexer. Scripts are stored in text files using the file extension .mps. Each script consists of a sequence of commands separated by line feeds and/or colons (":"). Commands and functions are case insensitive. Comments ca be stored in a script file using the equal sign ("="). The language has conditional (IF...[ELSE...]ENDIF, REPEAT...UNTIL, WHILE...ENDWHILE) and unconditional flow control commands (CALL, GOTO and LOOP). Data can be stored in variables of various data types (TEXT, CHAR, BYTE, SIGBYTE, WORD, SIGWORD, LONGWORD, SIGLONGWORD, SIGQWORD, SINGLE, DOUBLE, EXTENDED, COMP, FILE and VARREF). Using the CALL() function and the LOCAL/ENDLOCAL commands you can implement custom subroutine functions.

A simple Tiny Hexer Script might look like the following (without line numbers):

1)    = Sample Script
2)    VAR txt TEXT
3)    @@LOOP_1
4)    LET txt = INPUT("Input Query", "Please enter some text (no text to exit)", txt)
5)    IF txt == "":END:ENDIF
6)    MSGBOX ("You entered:\r\n"+txt), 0x40
7)    GOTO LOOP_1

Description

Line 1): The equal sign ("=") tells Tiny Hexer to ignore the rest of this line (used to store comments in the script file).

Line 2): The variable txt of data type TEXT is defined (all variables must be defined in Tiny Hexer Script before they can be used).

Line 3): The label LOOP_1 is defined. Labels are used to name subroutines (CALL and LOOP commands) and targets for the GOTO command.

Line 4): The result of the function INPUT(...) is assigned to the variable txt.

Line 5): This line consists of three commands, separated by colons. The first command (IF) checks if the condition (txt == "") is met. If yes, the following command is executed. If not, the script continues at the command after the ENDIF command. The second command (END) tells Tiny Hexer to stop execution of the script. The third command (ENDIF) terminates the IF block.

Line 6): The MSGBOX command is executed to show a message to the user (the text he entered in this case).

Line 7): The GOTO command tells Tiny Hexer to continue script execution at label LOOP_1.

Localizing Scripts

You can write localized versions of Tiny Hexer scripts. If you have an english version of a script called "myscript.mps" and also want to make available a german version of the script depending on the current language of Tiny Hexer, you simply have to name the german script version "myscript.mps.deu", Tiny Hexer will automatically choose "myscript.mps.deu" if if the german version is being executed (see LANGUAGE_EXT for available languages). This also applies to the INCLUDE preprocessor directive.


Tiny Hexer Script: Data types

Tiny Hexer Script uses different data types. They are explained here.
  • Overview
  • Literals
  • TEXT type
  • CHAR type
  • BYTE type
  • SIGBYTE type
  • WORD type
  • SIGWORD type
  • LONGWORD type
  • SIGLONGWORD type
  • SIGQWORD type
  • SINGLE type
  • DOUBLE type
  • EXTENDED type
  • COMP type
  • FILE type
  • VARREF type

Overview

Variables, commands, functions and expressions in Tiny Hexer Script use or have different data types. Using the wrong data type will lead to "Type mismatch" errors during script compilation or execution.

Numeric data types:

- Ordinal (integral) numeric data types:

The BYTE (1 byte, unsigned), SIGBYTE (1 byte, signed), WORD (2 byte, unsigned), SIGWORD (2 byte, signed), LONGWORD (4 byte, unsigned, aka DWORD), SIGLONGWORD (4 byte, signed) and SIGQWORD (8 byte, signed, aka QWORD) data types are used to store integral numeric values.

- Floating point numeric data types:

The SINGLE (4 bytes, 7..8 significant digits), DOUBLE (8 bytes, 15..16 significant digits), EXTENDED (10 bytes, 19..20 significant digits) and COMP (8 bytes, signed, range -2**63+1..2**63-1) data types are used to store floating point numeric values.

Textual data types:

The TEXT and CHAR data types are used to store textual data. TEXT data can hold whole text strings, the CHAR type can hold only one character (1 byte).

Other data types:

See FILE and VARREF later in this section.

Type compatibility and conversion:

All integral numeric data types are compatible, though assigning a value greater than the target type's range will lead to incorrect results (e.g. assigning the value 258 to a BYTE type variable will lead to a range overflow, so actually the value 2 is stored in that variable: 0x0102 -> 0x02).
The CHAR data type is also compatible to integral numeric data types, the byte value of the character stored is used if a CHAR is used as a numeric data.

All floating point numeric data types are interchangeable in general, but there may occur rounding errors and even floating point exceptions when assigning a more exact fp data type to a less exact fp data type (e.g. when assigning an extended to a single).
Floating point calculations are always done using extended data types.
You can also assign all integral numeric literals, expressions and variables to extended data types.

TEXT and CHAR textual data types are compatible, so a CHAR data can be used where a TEXT data is expected. If a TEXT data is used where a CHAR is expected, the first character of the TEXT data is used. If the data contains an empty text, an error is raised.

To convert textual or floating point data to integral numeric data, use the BYTE(), SIGBYTE(), WORD(), SIGWORD(), LONGWORD(), SIGLONGWORD() and SIGQWORD() functions. Those functions raise an error if the data string or floating point value cannot be converted to an integral number (e.g. '0x200', '-345', '755o', 7.5 are convertible values, 'notanumber' and 2.3E-188 aren't).

To convert textual or integral numerical data to a floating point value, use the SINGLE(), DOUBLE(), EXTENDED() and COMP() functions. Those functions raise an error if conversion fails.

To convert numeric data to text, use the CHAR() and TEXT() functions. The format of the resulting text string when using the TEXT() functions depends on the values of NUMBER_PREFIX, NUMBER_SUFFIX and NUMBER_RADIX. To avoid using the NUMBER_... special variables when converting integral numerical values to text, you can also use the functions BIN(), DEC(), HEX() and OCT().

The FILE type is compatible with itself only.

The VARREF type is compatible with itself only, but you can use the DEREF() function to retrieve the value of the referenced variable. Use the @ operator to assign a variable to a VARREF data.

Literals

Tiny Hexer Script supports textual and numeric literals in different formats.

Textual literals can be written down in a script in three different formats:

  • Single quoted text literals (textual data enclosed by single quotes (apostrophes)):
    Each character between the enclosing single quotes is read as is, e.g.:
    VAR t TEXT

LET t='the char combination \n has no special meaning in single quoted text literals'

    results in
    the char combination \n has no special meaning in single quoted text literals
  • Double quoted text literals (textual data enclosed by double quotes (")):
    The backslash "\" is used as meta/escape character, so is it possible to write down "untypeable" characters in the script. the following meta combinations are recognized:

    • \t: character with the ascii value 9 (tabulator)
    • \n: character with the ascii value 10 (line feed)
    • \r: character with the ascii value 13 (carriage return)
    • \\: single backslash
    • \0X<2 digit hex number>: character with the ascii value of <2 digit hex number>
    e.g.:
    VAR t TEXT

LET t="the char combination \n stands for a line feed in double quoted text literals"

    results in
    the char combination
stands for a line feed in double quoted text literals
  • Here Documents (multiline textual data enclosed by double less-than-signs and double greater-than-signs (<< >>)):
    Each character between the opening mark (<<) and the closing mark (>>) is read literally, even line feeds. The opening mark must be the last part of a script line, the closing mark must be on its own script line. The last line feed is not read into the resulting textual literal, e.g.:
    VAR t TEXT

LET t= <<
this is a multiline (here document like) textual literal.
the line feeds in the script are part of the literal.
neither ' nor " mark the end of the literal,
just a double greater-than-sign (>>) left alone on a
script line finishes the literal.
>>

= now go on with other script commands...

    results in
    this is a multiline (here document like) textual literal.
the line feeds in the script are part of the literal.
neither ' nor " mark the end of the literal,
just a double greater-than-sign (>>) left alone on a
script line finishes the literal.

Ordinal (integral) numeric literals (numerals) can be written down in a script in four different formats:

  • Decimal numeric literals:
    Decimal numeric literals consist of sequences of numeric characters (0,1,2,3,4,5,6,7,8,9) and may be prefixed by a minus sign "-" to indicate a negative number, e.g.
    VAR i SIGQWORD
LET i=-912340

  • Hexadecimal numeric literals:
    Hexadecimal numerals are prefixed by "0x" and consist of sequences of hexadecimal digits (0..9, A..F), e.g.
    VAR i SIGQWORD
LET i=0xAFD245FE

  • Binary numeric literals:
    Binary numeric literals are prefixed by the percent sign "%" and consist of sequences of binary digits (0,1), e.g.
    VAR i SIGQWORD
LET i=%011010100010110

  • Octal numeric literals:
    Octal numeric literals consist of sequences of octal digits (0,1,2,3,4,5,6,7) and are immediately suffixed by the letter o, e.g.
    VAR i SIGQWORD
LET i=0755o

Numeric floating point literals can only be written in decimal notation. The dot character "." is used as the decimal separator. You can also use the scientific notation ("E" character followed by the decimal exponent).

  • Some examples for valid floating point numerals:
    0.234
1234E16
-667.8885e-9
-0.000089

TEXT data type

TEXT data is used to store textual data (using the DATA2TEXT() and TEXT2DATA() functions TEXT data can store any data and even some kind of array fields). TEXT data can store from 0 up to (2**31 - 1) data characters (depending on available memory), the amount of data stored in a TEXT data can be retrieved using the TEXTLEN() function.

TEXT literals can be written using textual literals.

CHAR data type

CHAR data is used to store single data characters (1 Byte).

CHAR literals can be written using either one-char textual or ordinal numeric literals.

BYTE data type

BYTE data is used to store 8 Bit (= 1 Byte) unsigned ordinal values.

BYTE literals can be written using ordinal numeric literals.

SIGBYTE data type

SIGBYTE data is used to store 8 Bit (= 1 Byte) signed numeric values. The most significant bit is used as sign indicator, so only 7 Bits are available for data.

SIGBYTE literals can be written using ordinal numeric literals.

WORD data type

WORD data is used to store 16 Bit (= 2 Byte) unsigned ordinal values.

WORD literals can be written using ordinal numeric literals.

SIGWORD data type

SIGWORD data is used to store 16 Bit (= 2 Byte) signed numeric values. The most significant bit is used as sign indicator, so only 15 Bits are available for data.

SIGWORD literals can be written using ordinal numeric literals.

LONGWORD data type (Alias: DWORD)

LONGWORD data is used to store 32 Bit (= 4 Byte) unsigned ordinal values.

LONGWORD literals can be written using ordinal numeric literals.

SIGLONGWORD data type

SIGLONGWORD data is used to store 32 Bit (= 4 Byte) signed numeric values. The most significant bit is used as sign indicator, so only 31 Bits are available for data.

SIGLONGWORD literals can be written using ordinal numeric literals.

SIGQWORD data type (Alias: QWORD)

SIGQWORD data is used to store 64 Bit (= 8 Byte) signed numeric values. The most significant bit is used as sign indicator, so only 63 Bits are available for data.

SIGQWORD literals can be written using ordinal numeric literals.

SINGLE data type

SINGLE data is used to store single precision signed floating point values in the range 1.5x10**-45 - 3.4x10**38. This type uses four bytes for data storage and has 7 - 8 significant digits.

SINGLE literals can be written using floating point numerals.

DOUBLE data type

DOUBLE data is used to store double precision signed floating point values in the range 5.0x10**-324 - 1.7x10**308. This type uses eight bytes for data storage and has 15 - 16 significant digits.

DOUBLE literals can be written using floating point numerals.

EXTENDED data type

EXTENDED data is used to store extended precision signed floating point values in the range 3.6x10**-4951 - 1.1x10**4932. This type uses ten bytes for data storage and has 19 - 20 significant digits.

EXTENDED literals can be written using floating point numerals.

COMP data type

COMP is a special data type native to the Intel cpu family. It stores a 64 bits signed integer value (like SIGQWORD) but it's defined as a floating point data type.

COMP literals can be written using ordinal numeric literals.

FILE data type

FILE data contain private structures used to access file handles in file related commands and functions.

VARREF data type

VARREF data structures contain references to variables and are used e.g. by the FILEREAD() function.


Tiny Hexer Script: Variables

In Tiny Hexer script you can use variables to store specific data.
  • Overview
  • Variable tagging
  • Special variables

Overview

Valid variable names are sequences of at least one alphanumeric character or the underline character (_). A variable name must not start with a number digit. Valid variable names are e.g. _1, Var1, _test_. Invalid variable names are e.g. 1var, v$a. Identifiers reserved in Tiny Hexer Script (like function and command names) cannot be used as variable names.

Variables must be declared before accessing them in a script using the VAR command. When a variable is declared using the VAR command, its data type is defined and cannot be changed afterwards.

To assign data to a variable, use the LET command.

By default, sub routines (CALL and LOOP commands) use copies of declared variables (like environmental variables in batch scripts), so the sub routine can access the variable and change its value locally, but after termination of the sub routine (RETURN command) the original value of the variable is restored. This behaviour can be changed using the OPTION GLOBALVARS directive.

Variable tagging

Variable tagging is used to create hyperlinks in the structure viewer. Each variable can have a position and length tag. Variable tagging is disabled by default, this behaviour can be controlled by the OPTION READTAGS directive.

If tagging is enabled, the FILEREAD command and function set the tag of the variable to the file position before reading and the amount of data being read. The following commands and functions allow you to access and modify variable tags: COPYTAGS, TAGVAR, TAG_POS() and TAG_LEN().

Special variables

The following special variables exist in Tiny Hexer:

  • ARGC (LONGWORD, readonly)

    Reading this variable returns the number of parameters passed by the CALL command and CALL() function.
    See also CALL() function and CALL command.

  • COMPARE_COUNT* (LONGWORD, readonly)

    Reading this variable returns the number of difference blocks after a file comparison has been made.
    See also COMPARE_START() and COMPARE_END().

  • CURRENTFILE* (TEXT, read/write):

    Reading this variable returns the filename of the active editor window. If no editor window is open, the variable contains an empty text. On setting this variable, Tiny Hexer tries to find an editor window whose filename matches the value and brings it to front. If no matching editor window is found, an error occurs.

  • ERRORLINE (LONGWORD, readonly):

    Reading this variable returns the number of the script line where the last error occurred.
    See also ERRORHANDLER, ERRORMESSAGE, ERRORNUMBER.

  • ERRORMESSAGE (TEXT, readonly):

    Reading this variable returns the textual representation of the last script error.
    See also ERRORHANDLER, ERRORLINE, ERRORNUMBER.

  • ERRORNUMBER (LONGWORD, readonly):

    Reading this variable returns the numerical value of the last script error. Some predefined errors exist, they are explained in the file scripts\inc\def.mps
    See also ERRORHANDLER, ERRORLINE, ERRORMESSAGE.

  • FILE_COUNT* (LONGWORD, readonly):

    Reading this variable returns the number of open editor files in Tiny Hexer.
    See also FILES().

  • FRANDOM (EXTENDED, read/write):

    Reading this variable returns a floating point random number in the range 0..1.
    Setting this variable changes the random seed value.
    See also QRANDOM, RANDOM().

  • GETTEMPFILENAME* (TEXT, readonly):

    Reading this variable returns a unique filename in Tiny Hexer's temporary directory.

  • LANGUAGE_EXT* (TEXT, readonly):

    this variable is mainly used in Tiny Hexer plugins. it tells the exe and plugin language extension currently being used (empty string if Tiny Hexer's language is English, '.DEU' if language is German).
    See also localizing scripts

  • LOOP (LONGWORD, readonly):

    On subroutine execution via the LOOP command, this variable contains the current loop index.

  • NUMBER_PREFIX (TEXT, read/write):

    Tells Tiny Hexer how it should convert numeric values to text using the TEXT() function (e.g. '0x': 48 -> '0x30', '$': 32 -> '$20').

  • NUMBER_RADIX (BYTE, read/write):

    Tells Tiny Hexer how it should convert numeric values to text using the TEXT() function (e.g. if set to 10, numbers are converted to decimal text, if set to 16, numbers are converted to hexadecimals and so on).

  • NUMBER_SUFFIX (TEXT, read/write):

    Tells Tiny Hexer how it should convert numeric values to text using the TEXT() function (e.g. 'h': 80 -> '50h').

  • PARAM_COUNT (LONGWORD, readonly):

    Stores the number of arguments passed to the script when it's started by a tools menu item.
    See also PARAMS().

  • PI (EXTENDED, readonly):

    This variable returns the value of the mathematical constant PI.

  • POSITION_COUNT* (LONGWORD, readonly):

    Reading this variable returns the number of entries in the position list.
    See also POSITIONS(), POSITION_ADD, POSITION_SELECTED(), POSITION_DESC.

  • POSITION_DESC* (TEXT):

    Sets or retrieves the text of the description in the position list.
    See also POSITIONS(), POSITION_ADD, POSITION_SELECTED(), POSITION_COUNT.

  • QRANDOM (SIGQWORD, readonly):

    Returns a 64 Bits wide random number.
    See also FRANDOM, RANDOM().

  • SCRIPTFILENAME (TEXT, readonly):

    Contains the file name of the script itself.

  • SCRIPTLINE (LONGWORD, readonly):

    Contains the current script line number.

  • SCRIPTPOS (LONGWORD, readonly):

    Contains the binary script position.

  • TYPEOFSTACK (LONGWORD, readonly):

    Retrieves the type of the data on top of the stack (the value retrieved by the POP command). Warning: Do not use this variable in complex expressions as they store temporary values on the stack themselves, rather assign this variable to a user variable before working with it's value.
    See also POP, TYPEOF().


Tiny Hexer Script: Expressions

Expressions in Tiny Hexer Script are constructs which return values.

Expressions can either consist of simple literals or variables of different data types or of complex constucts which are build using parenthesis, literals, operators and functions.
Sample expressions:
var1                := variable
@var1               := variable reference
224                 := BYTE literal
0xE0                := hexadecimal BYTE literal
'Hello, world'      := TEXT literal
"Hello, world\n\r"  := TEXT literal
FILESIZE(f)         := function call
a * b               := product of a and b
var1 / (1 - var1)   := quotient of var1 and (1 - var1)
var1 != 2           := TRUE/FALSE condition (BYTE data type)
not var1            := negation of a TRUE/FALSE condition


Tiny Hexer Script: Operators

Operators in Tiny Hexer Script are used to construct expressions.
  • Overview
  • Numeric operators
  • TEXT operators
  • Relational operators
  • Reference operator @
  • Operator precedence

Overview

Operators are used to build expressions by taking an action on one or two parameters. Those parameters are called operands. Operators taking one operand are unary operators, operators taking two operands are called binary.

Unary operators (like @, - and not) always precede their operand (e.g. -3).

Binary operators (like *, mod or !=) are always placed between their operands (e.g. 3 * 4).

The operators + and - can be either unary (e.g. -3) or binary (e.g. 4 - 3).

The behaviour of some of the operators depends on the data types of their operands (e.g. "ab" * 3 results in "ababab", 4 * 3 results in 12).

Numeric operators

Numeric operators are used to do numeric calculations.

The following binary numeric operators exist in Tiny Hexer Script:

  • +: calculate the sum of the operands (3 + 4 → 7)
  • -: calculate the difference of the operands (4 - 3 → 1)
  • *: calculate the product of the operands (3 * 4 → 12)
  • **: calculate the power of the operands (3 ** 4 → 81)
  • /: calculate the integral quotient of the operands (8 / 3 → 2)
  • //: calculate the floating point quotient of the operands (8 // 3 → 2.66666...)
  • MOD: calculate the remainder of the integral quotient of the operands (8 MOD 3 → 2)
  • AND: bitwise and of the operands (%1100 AND %0101 → %0100)
  • OR: bitwise or of the operands (%1100 OR %0101 → %1101)
  • XOR: bitwise exclusive or of the operands (%1100 XOR %0101 → %1001)
  • <<: shift operand1 operand2 bits to the left (%0011 << 2 → %1100)
  • >>: shift operand1 operand2 bits to the right (%1100 >> 2 → %0011)

The following unary numeric operators exist in Tiny Hexer Script:

  • +: returns the value (+4 → 4)
  • -: negates the sign of the value (x=-4:-x → 4)
  • NOT: returns TRUE (=1) if the operand equals to 0, FALSE (=0) otherwise (NOT 0 → 1, NOT 7 → 0)

TEXT operators

TEXT operators are used to modify TEXT string values.

The following binary TEXT operators exist in Tiny Hexer Script:

  • +: concats both TEXT operands and returns the resulting TEXT ("foo" + "bar" → "foobar")
  • *: concats the TEXT operator1 operator2 times ("foo" * 4 → "foofoofoofoo")

Relational operators

Relational operators are used to compare their two operands. Both operands must be of compatible data types, but FILE and VARREF types cannot be compared.

If comparsion succeeds, TRUE (=1) is returned, FALSE (=0) otherwise.

The following binary relational operators exist in Tiny Hexer Script:

  • ==: equals operand1 to operand2? (4 == 3 → 0)
  • !=: do operand1 and operand2 differ? ("foo" != "bar" → 1)
  • <=: is operand1 less than or equal to operand2? (4 <= 3 → 0)
  • >=: is operand1 geater than or equal to operand2? (4 >= 3 → 1)
  • <: is operand1 less than operand2? (4 < 3 → 0)
  • >: is operand1 geater than operand2? (4 > 3 → 1)

The reference operator @

The unary @ operator returns an expression of type VARREF. Its operand must be a variable. This operator is used to store not only the value of a variable, but a reference to the variable itself. To retrieve the variable that is referenced by a VARREF expression, use the DEREF() function.

Some functions (like FILEREAD()) need VARREF parameters to be able to get directaccess to the variable (e.g. for variable tagging).

If you change the value of the variable that is referenced by a VARREF expression, a DEREF() call always returns the actual value of that variable, not the value that was stored at the time the assignment has been made:

@ sample:
VAR a TEXT b TEXT r VARREF

= assign a value to a
a="foo"

= store the value in b
b=a

= store the variable itself in r
r=@a

= now change the value of a
a="bar"

= b still contains "foo"
MSGBOX b

= r points to a, so the current value of a is shown
MSGBOX DEREF(r)

Operator precedence

In expressions containing multiple operators, the order of operator computation depends on precedence rules. Operators with higher precedence are evaluated before operators with lower precedence. To break those precedence rules, you can use parenthesis:

4 + 3 * 7 → 25. The multiplication (3 * 7) is calculated before the sum (4 + 21), because the * operator has a higher precedence than the + operator.

(4 + 3) * 7 → 49 breaks this rule because the sum is calculated before the product.

Precedences (in descending order, the first operator has the highest precedence):

  • @
  • unary +, unary -, NOT
  • **
  • AND, *, MOD, <<, >>, /, //
  • OR, XOR, +, -
  • ==, !=, <=, >=, <, >


Tiny Hexer Script: Directives

Directives are used to control the compilation of Tiny Hexer Scripts.

Directives tell Tiny Hexer how to compile Tiny Hexer Scripts. Only the compilation of commands following a directive is affected by that directive. Directives are written in the form

OPTION <name of the directive> <value>

Currently the following directives are supported:
OPTION GLOBALVARS, <0 or 1>

If GLOBALVARS is set to 1, only one set of variables exist, so non-local subroutines (called by the CALL and LOOP commands and the CALL() function) can change variables globally.

When set to 0 (default), subroutines get their own copy of all variables, so they can change them locally, but on termination of the subroutine (RETURN command), changes are lost and the variable contents are reset to the values before calling the subroutine.

Local subroutines are affected only if they do not redefine global variables (otherwise the variables become local to the subroutine and their values are not derived from the equal-named global variables).

See also variables.
OPTION OPT1,"<text>"
OPTION OPT2, "<text>"
OPTION OPT3, "<text>"
OPTION OPT4, "<text>"
OPTION OPT5, "<text>"

These directives are used to control user defined settings. OPT3, OPT4 and OPT5 are not yet used. OPT2 and OPT1/OPT2 are used in import and export scripts, respectively. OPT5 is used to define an icon for scripts listed under the Tools/Scripts menu
OPTION READTAGS, <0 or 1>

If READTAGS is set to 1, the FILEREAD command and function store the current file position and amount of data read.

See also variable tagging.
OPTION TARGET, <IMPORT, EXPORT or STRUCTUREVIEWER>

Using the TARGET directive you can tell Tiny Hexer that a script is not an ordinary one, but should be used with the "File/Import" command, the "File/Export" command or the structure viewer. If such a script is opened using the "Tools/Execute script" command, a warning message is displayed telling the user that the script is not designed to be executed directly. Also the structure viewer and the import/export commands refuse to use scripts not designed for them.
OPTION TITLE,"<text>"

Using the TITLE directive you can set the caption of the structure viewer, list entries in "Import" and "Export" dialogs and the "Tools/Scripts" menu commands.
See the topic about localizing scripts for localized TITLE directives.
OPTION UNDO, <0 or 1>

If UNDO is set to 1 (default), the contents of the currently active editor are stored internally before the script is executed to allow for restoring the file's previous state after the script finishes. If you are sure the script will not change the current editor's data (or the file is rather large), you can set UNDO to 0 to avoid unnecessary memory consumption.


Tiny Hexer Script: Commands

This page shows all available Tiny Hexer Script commands. Note: As of version 1.6.0.2 of Tiny Hexer most functions can be used like commands, i. e. functions which have no equally named command counterpart can be used as first keyword in a script line (in this case the function's result is discarded).
! @ C D E F G I L M O P R S T V W
CALL target [, param1, param2...]
Parameters:

target: the name of a label or local label in the current script
param1/2...: optional expressions that are pushed to the stack

more...

less...

CALL continues script execution at the position marked with the label target after storing the current command position internally. The RETURN or ENDLOCAL commands are used to finish a LABEL or LOCAL subroutine, respectively. After calling a subroutine, script execution continues at the command following the CALL command.

The CALL command can have optional parameters that are pushed to the stack. The subroutine can retrieve those parameters using the POP command. (Note: Because the stack is a LIFO, the first POP in a subroutine returns the last parameter, the second POP returns the last but one parameter...). The called sub block can retrieve the number of parameters pushed to the stack by reading the ARGC special variable.
See also: CALL() function, LABEL, LOCAL...ENDLOCAL, RETURN, LOOP, ARGC special variable, GOTO, PUSH, POP, OPTION GLOBALVARS directive.
Sample:
VAR t1 TEXT,  t2 TEXT

= pushes 'first', than 'second' to the stack and calls the label concat
CALL concat, "first", "second"

= use the END command to avoid running into the subroutine again
END

LABEL concat
POP t1
= t1 now contains 'second' (the last parameter pushed to the stack)

POP t2
= t2 now contains 'first' (the last-but-one parameter pushed to the stack)

= displays the message 'second first' !!!
MSGBOX t1+" "+t2

= return from the subroutine to the command following the CALL
RETURN
CONCAT textvar, textexpr
Parameters:

textvar: the name of a text variable
textexpr: an expression of type text

more...

less...

CONCAT concats the value of the text-type expression textexpr to the text already stored in the text-type variable textvar. (Note: The CONCAT command is faster than the text-type '+' operator.)
See also: text-type '+' operator, INC.
Sample:
VAR txt TEXT

= variable txt is set to the text 'foo'.
LET txt = "foo"

CONCAT txt, "bar"
= variable txt now contains the text 'foobar'.
COPYTAGS targetvar, sourcevar
Parameters:

targetvar and sourcevar: variable names

more...

less...

The COPYTAGS command is used to assign the tag of variable sourcevar to variable targetvar.
See also: Variable tagging, TAGVAR, TAG_POS() function, TAG_LEN() function, OPTION READTAGS directive.
Sample:
VAR foo TEXT, bar TEXT, tagstorage TEXT

= sets the tag_pos field of the variable foo to 2000 and the tag_len field to 4
TAGVAR foo, 2000, 4

= copies the tag of the variable foo to the variable bar
COPYTAGS bar, foo

= enable decimal number to text conversion
NUMBER_PREFIX=''
NUMBER_SUFFIX=''
NUMBER_RADIX=10

= assigns the tag_pos field of bar to the variable tagstorage
LET tagstorage = TEXT(TAG_POS(@bar))

= displays the tag_pos field of variable bar
MSGBOX ("The Tag position of bar is: "+tagstorage)
DEF name value
Parameters:

name: a valid identifier name
value: an expression

more...

less...

The DEF preprocessor statement is used to give certain expressions or values descriptive names (similar to #define in the C programming language). After assigning a descriptive name to a value, this name stands for the value in the script.
Sample:
= tell Tiny Hexer Script to substitute all literal occurances of FOOBAR with 'Foo/Bar'
= and all literal occurances of MYMESSAGE with FOOBAR+'/whatsoever'
DEF FOOBAR 'Foo/Bar'
DEF MYMESSAGE FOOBAR + '/Whatsoever'

= show if it works
MSGBOX MYMESSAGE
DLLFUNC name dllname [name funcname | index funcindex] [out outvartype] [in [@]invartype1 [, [@]invartype2...]]
Parameters:

name: a valid identifier name
dllname: the name of a dynamic link library containing the function
funcname: the optional name of the function as it is called in the dll
funcindex: the optional index to the function in the dll
outvartype, invartype1, invartype2...: optional types of return value of the function and calling parameters

more...

less...

The DLLFUNC preprocessor statement is used to declare stdcall functions stored in dynamic link libraries so they can be executed from within Tiny Hexer Script. After declaring a function from a dll, that function can be used like builtin functions in the script using the name identifier.
dllname is the name of the dynamic link library where the function resides.

The optional name funcname or index funcindex parameters are used to define functions using different names in the script and the library.

The optional out outvartype parameter tells the scripting engine the type of the data the function returns. If no outvartype is specified, the engine assumes a void function (that is a procedure) is to be called. The following data types are supported: TEXT (assumes LPCHAR), CHAR, BYTE, WORD, LONGWORD, SIGBYTE, SIGWORD and SIGLONGWORD.

The optional in invartype parameters tell the scripting engine the type of the data to pass to the function. If no invartypes are specified, the engine assumes that no parameters should be passed to the function. The following data types are supported: TEXT, WORD, LONGWORD, SINGLE, SIGWORD, SIGLONGWORD (by Value) and TEXT, CHAR, BYTE, WORD, LONGWORD, SIGQWORD, DOUBLE, SINGLE, EXTENDED, COMP, SIGBYTE, SIGWORD, SIGLONGWORD (by Reference). To distinguish by value parameters from by reference parameters, prefix the by reference (pointer to the data) type declarations by an at sign (@).

Notes: To use data types unknown to Tiny Hexer Script (like WinAPI structures), you can use "static" TEXT type parameters, that is TEXT parameters with a specific length (usually the size of the corresponding native structure). To define static TEXT parameters, tell DLLFUNC the size of the structure by using the suffix [size] to the TEXT type.

TEXT and CHAR parameters are always pushed as data pointers (by reference) on the stack, the difference between byval and byref (the latter one with @ prefix) is that an unique amount of memory is allocated for byref TEXT parameters.
Sample:
= use WINAPI functions to get and show the creation date/time of a selected file
= used WINAPI functions and structures:
= FindFirstFileA, FindCloseA, _WIN32_FIND_DATAA=TEXT[320] (size of this structure)
= FileTimeToLocalFileTime, FileTimeToSystemTime, _SYSTEMTIME=TEXT[16]
= GetTimeFormat, GetDateFormat
INCLUDE 'def.mps'
DLLFUNC FindFirstFile kernel32.dll name FindFirstFileA out LONGWORD in TEXT @TEXT[320]
DLLFUNC FindClose kernel32.dll out LONGWORD in LONGWORD
DLLFUNC FileTimeToLocalFileTime kernel32.dll in @SIGQWORD @SIGQWORD out LONGWORD
DLLFUNC FileTimeToSystemTime kernel32.dll out LONGWORD in @SIGQWORD @TEXT[16]
DLLFUNC GetTimeFormat kernel32.dll name GetTimeFormatA in DWORD DWORD TEXT[16] TEXT @TEXT SIGLONGWORD out SIGLONGWORD
DLLFUNC GetDateFormat kernel32.dll name GetDateFormatA in DWORD DWORD TEXT[16] TEXT @TEXT SIGLONGWORD out SIGLONGWORD

= select the file
VAR filename TEXT
filename = ASKOPENFILENAME("Select a file", "All Files (*.*)|*.*")

= try to get the file record
VAR findrec TEXT findhandle LONGWORD
findhandle = FINDFIRSTFILE(filename, @findrec)
IF findhandle == 0xffffffff
  ERROR "Cannot find record for file "+filename
ENDIF

= close the FindFirstFile handle
FINDCLOSE(findhandle)

= get the "Creation time" _FILETIME record in the findrec structure (at position 5)
= dirty hack, but ths actually doesn't support structures ;-)
VAR filetime SIGQWORD:= _FILETIME is eight bytes in size, so we can use this variable type
findrec = TEXTCOPY(findrec, 5, 8)
filetime = TEXT2DATA(findrec, 0, -SIGQWORD_DATA)

= convert the filetime to a local filetime
VAR lfiletime SIGQWORD
IF (NOT FileTimeToLocalFileTime(@filetime, @lfiletime))
  ERROR "Cannot convert file time to local filetime"
ENDIF

= convert the local filetime to a systemtime
VAR systemtime TEXT
IF (NOT FileTimeToSystemTime(@lfiletime, @systemtime))
  ERROR "Cannot convert file time to systemtime"
ENDIF

LOCAL SystemTimeToString:= convert a _SYSTEMTIME to a date/time string
  = params in systemtime (text[16]) out text
  VAR in TEXT out TEXT temp TEXT nil NONE len SIGLONGWORD
  POP in
  temp = (CHAR(0)+CHAR(0)) * 128:= prepare a buffer
  len = GetDateFormat(1 << 10 ,0, in, nil, @temp, 256)
  IF (len == 0)
    ERROR "Cannot convert date to string"
  ENDIF
  out = TEXTCHOP(TEXTCOPY(temp, 1, len))+' '
  temp = (CHAR(0)+CHAR(0)) * 128:= prepare a buffer
  len = GetTimeFormat(1 << 10 ,0, in, nil, @temp, 256)
  IF (len == 0)
    ERROR "Cannot convert time to string"
  ENDIF
  CONCAT out TEXTCHOP(TEXTCOPY(temp, 1, len))
  RETURN out
ENDLOCAL

= convert the resulting _SYSTEMTIME to a text string
VAR timestring TEXT
timestring = #SystemTimeToString(systemtime)

= show result message
MSGBOX ("The file "+filename+" has been created on "+timestring)
END

more...

less...

The END command is used to stop script execution.
Sample:
VAR foo TEXT

END
= script execution is terminated at this position

LET foo = "bar"
= this command is never executed
ERROR textexpr
Parameters:

textexpr: an expression of type text

more...

less...

The ERROR command displays an error message textexpr and terminates script execution.
Sample:
VAR dividend LONGWORD divisor LONGWORD quotient LONGWORD

= enter divisor and dividend
LET dividend = LONGWORD(INPUT('Enter dividend:'))
LET divisor = LONGWORD(INPUT('Enter divisor:'))

IF ((divisor == 0) OR (dividend == 0))
  = throw an errror message and terminate the script
  ERROR "Neither dividend nor divisor must be zero!"
ELSE
  LET quotient = dividend / divisor:= calculate quotient

  = enable decimal number to text conversion
  NUMBER_PREFIX=''
  NUMBER_SUFFIX=''
  NUMBER_RADIX=10

  MSGBOX ("Result: "+TEXT(quotient))
ENDIF
ERRORHANDLER target | NONE
Parameters:

target: name of a label in the current script (or the special value NONE to disable error handling)

more...

less...

The ERRORHANDLER command allows to continue script execution at the label target if an error occurs. If the argument NONE is passed to the command, error handling is disabled, so the script will be terminated on error (default).

(Note: if an error occurs at script execution and the label target is called, error handling is automatically disabled to avoid possible infinite recursions caused by errors in the handler itself)
See also: ERRORLINE, ERRORMESSAGE and ERRORNUMBER special variables.
Sample:
INCLUDE 'def.mps'

VAR a LONGWORD, b LONGWORD

ERRORHANDLER errorlabel

= if an invalid numerical value is entered, the script is continued at
= the @errorlabel position
@@inputa:a= LONGWORD(INPUT('enter number 1'))
@@inputb:b= LONGWORD(INPUT('enter number 2'))

MSGBOX TEXT(a+b)

= force an error message
a = "this does not work, since a is a numerical variable!"

END

@@errorlabel

= exit if cancel command has been invoked
IF (ERRORNUMBER == ERROR_ABORT):END:ENDIF

ERRORHANDLER errorlabel:= reenable error handler

= if error occured in line  9 (@@inputa...), goto @@inputa,
= if error occured in line 10 (@@inputb...), goto @@inputb
IFGOTO ERRORLINE, 9, inputa, 10, inputb

= show error message and exit otherwise
ERRORHANDLER NONE
ERROR ERRORMESSAGE
EXTERN 'cmdname' [, param1, param2...]
!cmdname [param1, param2...]
Parameters:

cmdname: the name of the external command to execute
param1/2...: optional expressions passed to the external command

more...

less...

EXTERN (alias !) is used to execute commands external to Tiny Hexer Script. Currently it can be used to activate items of the Tiny Hexer main menu and to execute functions in Tiny Hexer plugins.

To execute a main menu entry, prefix the name of the menu command by 'CMD.'. Some of the commands can make use of additional parameters (like a filename for the CMD.FileOpen command).

List of menu commands and their parameters

To execute a function in a plugin, use the EXTERN 'PLUGIN'... or !PLUGIN... syntax.
(See the sources of "exporter.ths" in the Plugin SDK for details).
Menu command execution samples:
= open a file in Tiny Hexer
EXTERN "CMD.FileOpen", 'c:\cmldr'
= alternative
!CMD.FileOpen 'c:\boot.ini'

= open a new editor window
!CMD.FileNew
Plugin execution sample:
= this is an excerpt from the html export script in scripts\export\ex-html.mps

= ...

= call the plugin (located in the tiny hexer root directory)
!PLUGIN (ENVPARSE('%apppath%')+"\\exporter.ths"), "HTML", '::current', outfn, start, amount
FILECLOSE file
Parameters:

file: a variable of type FILE

more...

less...

The FILECLOSE command is used to close a file previously opened by FILEOPEN.
See also: FILEOPEN() function, FILEREAD, FILEWRITE.
Sample:
VAR f FILE, line TEXT

LET f = FILEOPEN('c:\autoexec.bat', 'r')
= opens the file c:\autoexec.bat for reading

FILEREADTEXTLINE f, line
= reads a line of text from the file

FILECLOSE f
= closes the file handle

MSGBOX ("Line: "+line)
= displays the line
FILEDELETE filename [, flags]
Parameters:

filename: an expression of type TEXT
flags: an optional expression of type BYTE

more...

less...

Use the FILEDELETE command to delete the file filename.

The optional flags parameter tells Tiny Hexer Script whether it should raise an error if the file to be deleted does not exist or cannot be deleted. If bit 0 (= value 1) of the flags parameter is not set, an error is raised if the file does not exist. If bit 1 (= value 2) is not set, an error is raised if the file cannot be deleted. Set flags to 3 to suppress all errors, set it to 0 (default) to check both conditions.
Sample:
= tries to delete the file, an error is raised if the file does not exist or cannot be deleted
FILEDELETE 'c:\test.tmp'

= tries to delete the file, don't care if the file does exist or can be deleted
FILEDELETE 'c:\test.tmp', 3
FILEREAD file, buffer [, count]
Parameters:

file: a variable of type FILE
buffer: a variable of type TEXT, CHAR, BYTE, WORD, LONGWORD or SIGQWORD
count: an optional expression of type LONGWORD

more...

less...

Use the FILEREAD command to read data from the file file into the variable buffer.

The optional count parameter tells Tiny Hexer Script how many bytes of data are to be read. If this parameter is omitted, the type of buffer defines the amount of data to be read (BYTE, CHAR: 1 Byte, WORD: 2 Bytes, LONGWORD: 4 Bytes, SIGQWORD: 8 Bytes, TEXT: reads from the file until EOF or a 0x00 byte is found).

If less data than expected has been read from the file, an error is raised. To avoid those errors (or if the exact amount of data that should be read from the file is unknown), use the FILEREAD() function instead of the command.
See also: FILEREAD() function, FILEWRITE, FILEOPEN() function, FILECLOSE, FILEREADTEXTLINE.
Sample:
VAR f FILE, wholedata TEXT

LET f = FILEOPEN('c:\autoexec.bat', 'r')
= opens the file c:\autoexec.bat for reading

FILEREAD f, wholedata
= reads all text from the file (only if no 0x00 byte is in the file)

FILECLOSE f
= closes the file handle

MSGBOX ("Contents: "+wholedata)
= displays the contents
FILEREADBE file, buffer
Parameters:

file: a variable of type FILE
buffer: a variable of type TEXT, CHAR, BYTE, WORD, LONGWORD or SIGQWORD

more...

less...

Use the FILEREADBE command to read data from the file file into the variable buffer if the file's contents are stored in BIG ENDIAN format (e.g. on Motorola CPUs).

The type of buffer defines the amount of data to be read (BYTE, CHAR: 1 Byte, WORD: 2 Bytes, LONGWORD: 4 Bytes, SIGQWORD: 8 Bytes, TEXT: reads from the file until EOF or a 0x00 byte is found).

If buffer is of type WORD, LONGWORD or SIGQWORD, the data is swapped after reading (e.g. LONGWORD = Byte 0 becomes Byte 3, Byte 1 becomes Byte 2, Byte 2 becomes Byte 1 and Byte 3 becomes Byte 0). On other data types, the command is similar to the FILEREAD command (except for the missing count parameter).

If less data than expected has been read from the file, an error is raised. To avoid those errors (or if the exact amount of data that should be read from the file is unknown), use the FILEREADBE() function instead of the command.
See also: FILEREADBE() function, FILEWRITEBE, FILEREAD.
FILEREADTEXTLINE file, txtbuffer [, breakonwhitespace]
Parameters:

file: a variable of type FILE
txtbuffer: a variable of type TEXT
breakonwhitespace: an optional expression of type BYTE

more...

less...

Use the FILEREADTEXTLINE command to read one line of text data from the file file into the text variable txtbuffer.

The end of a line is marked using 0x0a, 0x0d, 0x0a+0x0d or 0x0d+0x0a characters. Those line separators are cut off from txtbuffer.

If the optional parameter breakonwhitespace is set to 1, all characters less than 0x20 act as line separators. Those line separators are cut off from txtbuffer.
See also: FILEREAD.
Sample:
VAR f FILE, line TEXT

LET f = FILEOPEN('c:\autoexec.bat', 'r')
= opens the file c:\autoexec.bat for reading

FILEREADTEXTLINE f, line
= reads a line of text from the file

FILECLOSE f
= closes the file handle

MSGBOX ("Line: "+line)
= displays the line
FILESEEK file, position [, origin]
Parameters:

file: a variable of type FILE
position: an expression of type LONGWORD
origin: an optional expression of type LONGWORD

more...

less...

Use the FILESEEK command to move the position pointer of file file to position position manually. FILEREAD... and FILEWRITE automatically adjust a file's position pointer to the following byte. Using FILESEEK you can randomly acces data in a file.

If the optional parameter origin is present, the way of calculating the new position changes. Setting origin to 0 (= FILE_BEGIN) sets the position pointer of the file to the absolute value position (default). Setting it to 1 (= FILE_CURRENT) adds the value of position to the current position. Setting it to 2 (= FILE_END) set the file's position pointer to the value of position + the file's size.
See also: FILESIZE(), FILEPOS().
Sample:
VAR f FILE, line TEXT, fpos LONGWORD, fname TEXT

LET fname = 'c:\dttest.txt'

IF FILEEXISTS(fname)
  = open the file for reading and writing
  LET f = FILEOPEN(fname, 'rw')
ELSE
  = create the file
  LET f = FILEOPEN(fname, 'c')
ENDIF

= get current date and time
LET line = ENVPARSE('%date% - %time%')

= set the file pointer to the file's end
FILESEEK f, 0, 2

= append date/time string to the file
FILEWRITE f, (line+"\r\n")

FILECLOSE f
= closes the file handle
FILESETPROP file, property, value
Parameters:

file: a variable of type FILE
property: an expression of type TEXT
value: an expression

more...

less...

FILESETPROP is used to change a special file's properties. To set a file's properties, it must have been opened with read-write access. property is the name of the property to be modified, value is the property's new value. The type of value depends on the property.

List of available properties

See also: FILEGETPROP() function, FILEOPEN() function.
Sample:
VAR newed FILE

= open a new editor window
LET newed = FILEOPEN('::new', 'c')

= set bytes per row property to 12
FILESETPROP newed, 'BytesPerRow', 12

= close the file
FILECLOSE newed
FILEWRITE file, data1 [, data2...]
Parameters:

file: a variable of type FILE
data1/2...: expressions of type TEXT, CHAR, BYTE, WORD, LONGWORD or SIGQWORD

more...

less...

Use the FILEWRITE command to write the contents of data1/2... to the file file.

The type of the data... expressions define the amount of data to be written to the file (BYTE, CHAR: 1 Byte, WORD: 2 Bytes, LONGWORD: 4 Bytes, SIGQWORD: 8 Bytes, TEXT: length of the text value).

If less data than expected has been written to the file, an error is raised. To avoid those errors, use the FILEWRITE() function instead of the command.
See also: FILEWRITE() function, FILEREAD, FILEOPEN() function, FILECLOSE.
Sample:
VAR f FILE, line TEXT, fpos LONGWORD, fname TEXT
LET fname = 'c:\test.txt'

= enter a line of text
LET line = INPUT('Enter a line of text')

= create the file
LET f = FILEOPEN(fname, 'c')

= write line to the file
FILEWRITE f, (line+"\r\n")

FILECLOSE f
= closes the file handle
FILEWRITEBE file, data1 [, data2...]
Parameters:

file: a variable of type FILE
data1/2...: expressions of type TEXT, CHAR, BYTE, WORD, LONGWORD or SIGQWORD

more...

less...

Use the FILEWRITEBE command to write the contents of data1/2... to the file file if the file's contents should be stored in BIG ENDIAN format (e.g. on Motorola CPUs).

The type of the data... expressions define the amount of data to be written to the file (BYTE, CHAR: 1 Byte, WORD: 2 Bytes, LONGWORD: 4 Bytes, SIGQWORD: 8 Bytes, TEXT: length of the text value).

If data... is of type WORD, LONGWORD or SIGQWORD, the data is swapped before writing (e.g. LONGWORD = Byte 0 becomes Byte 3, Byte 1 becomes Byte 2, Byte 2 becomes Byte 1 and Byte 3 becomes Byte 0). On other data types, the function is similar to the FILEWRITEBE() function.

If less data than expected has been written to the file, an error is raised. To avoid those errors, use the FILEWRITEBE() function instead of the command.
See also: FILEWRITEBE() function, FILEREADBE, FILEWRITE.
GOTO target
Parameters:

target: name of a label in the current script

more...

less...

GOTO continues script execution at the position marked with the label target.

Contrary to the CALL command, GOTO doesn't store the current script position before going to the marked command, so the RETURN command cannot be used to return from the subroutine.

GOTO cannot not be used in LOCAL subroutines to leave the local scope.
See also: CALL, LABEL.
Sample:
= goto the end of the script
GOTO end_of_script

= the following command is never executed
MSGBOX "This message will never be shown"

LABEL end_of_script
END
IF condition : ifblock [ : ELSE : elseblock] : ENDIF
Parameters:

condition: a numeric expression
ifblock, elseblock: a sequence of Tiny Hexer Script commands

more...

less...

IF... commands are used to execute a sequence of commands (ifblock) only if the numeric expression condition equals to a value other than 0.

If the optional ELSE branch is present, the elseblock command sequence is executed otherwise.

The ENDIF statement terminates the ifblock or the elseblock sequence.
See also: REPEAT...UNTIL, WHILE...ENDWHILE.
Sample:
= decimal number to text
LET NUMBER_RADIX = 10
LET NUMBER_PREFIX = ''
LET NUMBER_SUFFIX = ''

MSGBOX "Guess a number game", 64

VAR number BYTE, entered BYTE

LABEL start

= randomly choose a number between 1 and 10
LET number = RANDOM(10)+1

LABEL loop

LET entered = BYTE(INPUT('Enter a number between 1 and 10'))
IF entered == number
  MSGBOX 'Right!'
ELSE
  IF number < entered
    MSGBOX ('My number is less than '+TEXT(entered))
  ELSE
    MSGBOX ('My number is greater than '+TEXT(entered))
  ENDIF
  GOTO loop
ENDIF

GOTO start
IFGOTO srcexpr, expr1, target1 [ , expr2, target2...]
Parameters:

srcexpr, expr1, expr2...: expressions
target1, target2...: labels in the current script

more...

less...

The IFGOTO command checks whether the value of one of the expressions expr1, expr2... is equal to the source expression srcexpr. if a match is found, the script is continued at the corresponding label (target1, target2...).
Sample:
VAR a byte

a = LONGWORD(INPUT('Enter a number between 1 and 5'))
IFGOTO a, 1, label1, 2, label2, 3, label3, 4, label4, 5, label5

= none of the allowed numbers has been entered, bail
ERROR 'Wrong number entered!'

VAR t TEXT

= make text from number
@@label1:t = 'one':GOTO labelout
@@label2:t = 'two':GOTO labelout
@@label3:t = 'three':GOTO labelout
@@label4:t = 'four':GOTO labelout
@@label5:t = 'five'

= output text number
@@labelout
MSGBOX t
INC numvar [, numexpr]
Parameters:

numvar: the name of a numeric variable (CHAR, BYTE, WORD, LONGWORD, SIGQWORD)
numexpr: optional numeric expression

more...

less...

INC adds the value of the numeric expression numexpr (defaults to 1 if not specified) to the value already stored in the numeric variable numvar. (Note: The INC command is faster than the numeric '+' operator.)
See also: numeric '+' operator, CONCAT.
Sample:
VAR number LONGWORD

= variable number is set to the value 10
LET number = 10

INC number, 20
= variable number now contains the value 30.
INCLUDE 'filename'
Parameters:

filename: filename of the script to be included

more...

less...

The INCLUDE preprocessor statement is similar to #include in the C programming language. It is used to replace itself by the contents of another script file. The syntax is very strict: The INCLUDE command must be the only command in a script line, the filename must be written literally in single quotes and between the INCLUDE statement and the first quote must be exactly one blank character. If the filename does not contain a path, the standard include path (<tiny hexer application path>\scripts\inc) is searched for the given filename.

As of version 1.6.0.2 of Tiny Hexer the filename may be abbreviated: an asterisk is replaced by the filename of the current script, not including path and file extension (e.g. if you want to include a file called "script.inc" in a script called "script.mps", you can write INCLUDE '*.inc')
Sample:
= include the standard definitions in def.mps
INCLUDE 'def.mps'

= show a warning message box
= MB_ICONWARNING is defined in def.mps
MSGBOX 'Warning!', MB_ICONWARNING
INIWRITE filename, section [, key [,value]]
Parameters:

filename, section, key: TEXT expressions
value: an expression

more...

less...

Use the INIWRITE command to write data to ini-style text files.

filename is the name of the ini file.
section is the name of the section in the ini file ([section] lines).
key is the name of the key in the ini file (the part to the left of the equal sign).
value is the data of the key (the part to the right of the equal sign).

If key and value are omitted, the whole section section is removed from the ini file.

If value is omitted, key is removed from section section in the ini file.
See also: INIREAD() function, REGWRITE command.
Sample:
DEF ini "c:\\mpthtest.ini"

= write some values to the ini file
iniwrite ini, "section 1", "key 1", 2
iniwrite ini, "section 1", "key 2", "abc"
iniwrite ini, "section 2", "key 1", 2
iniwrite ini, "section 2", "key 2", "abc"

= remove section 2 from the ini file
iniwrite ini, "section 2"

= remove section 1/key 2 from the ini file
iniwrite ini, "section 1", "key 2"

VAR val LONGWORD

= try to read the section 1/key 1
IF INIREAD(ini, "section 1", "key 1", @val)
  MSGBOX ('Value of section 1/key 1: '+TEXT(val))
ELSE
  ERROR ('Cannot read section 1/key 1 value from '+ini)
ENDIF
LABEL name
@@name
Parameters:

name: name of the label

more...

less...

The LABEL statement (alias @@) marks the following command with the identifier name, so the CALL, GOTO and LOOP commands and CALL() function can "jump" to this position. (Note: As of version 1.7 of Tiny Hexer, you may and should use LOCAL...ENDLOCAL constructs to define subroutines.)
See also: CALL, CALL(), GOTO, LOCAL...ENDLOCAL, LOOP.
Sample:
INCLUDE 'def.mps'
MSGBOX "To stop this script, press the 'Alt' key", MB_ICONINFORMATION

= mark the first command with 'start'
LABEL start

= infinite loop
GOTO start

= alternate syntax
@@start1

= infinite loop
GOTO start1
LET var = expr
var = expr
Parameters:

var: variable
expr: expression

more...

less...

The LET command is used to assign the value of expression expr to the variable var. This assignment succeeds only if the data types of var and expr are compatible.

Variables must be defined using the VAR command before data can be assigned to them.

In unambigous cases, the LET keyword may be omitted.
See also: Variables, VAR, Type compatibility.
Sample:
= define some variables
VAR t1 TEXT, c1 CHAR, b1 BYTE, d1 LONGWORD

= success
LET t1 = c1
c1 = t1

b1 = d1
LET d1 = b1

= because the CHAR type is compatible to numeric and text data types,
= the following assignments also will succeed
LET b1 = c1
LET c1 = d1

= to assign incompatible data types, use the conversion functions
LET t1 = TEXT(b1)
LET t1 = '0':LET d1 = LONGWORD(t1)

= these assignments will fail
LET t1 = b1
LET d1 = t1
LOCAL name : block : ENDLOCAL
Parameters:

name: name of the subroutine (label name)
block: a sequence of Tiny Hexer Script commands

more...

less...

LOCAL...ENDLOCAL constructs are used to define subroutines. They can be put anywhere in a Tiny Hexer Script, normal script operation does not execute such blocks until they are explicitly called by using the CALL or LOOP commands or the CALL() function.

You may redefine variables in local blocks, then they become local to that block, i.e. they do not inherit the value (and type) of an equally named global variable.

LOCAL...ENDLOCAL blocks cannot be nested. The RETURN command can be used to send a value back to a CALL() function.
See also: CALL, CALL(), LABEL, LOOP, RETURN.
Sample:
= this script shows the difference between a call to a LABEL
= and a call to a LOCAL block

= don't use global variables, so CALL <LABEL> (= #<LABEL>) make
= them locally as CALL <LOCAL> (= #<LOCAL>) does, but there
= are still differences
OPTION GLOBALVARS, 0

= predefine global variables
VAR t1 TEXT t2 TEXT
LET t1 = "a"
LET t2 = "b"

= you must skip over a label block to avoid running into it
GOTO start

= normal sub routine
= aka @@label_block
LABEL label_block

VAR cnt BYTE:= global variable!

POP cnt
POP t1
CONCAT t1, t2:= t2 is a local copy of the global variable and thus it does
= inherit the global value "b"

= two iterations
IF (cnt == 2): CONCAT t1, #label_block(t1,1): ENDIF

= end the label block and return
RETURN t1

@@start

= local blocks can be put anywhere in a script, they are not executed during
= normal script operation
LOCAL local_block

  = redefine variables, so changes become local
  VAR t1 TEXT t2 TEXT cnt BYTE:= local variables!

  POP cnt
  POP t1
  CONCAT t1, t2:= t2 is a totally local variable and does not inherit
  = the global value, so it is empty

  = two iterations
  IF (cnt == 2): CONCAT t1, #local_block(t1,1): ENDIF

  = end the label block and return
  RETURN t1

  = end the local block
ENDLOCAL
= the script is continued after an ENDLOCAL during normal operation

VAR output TEXT:= output for textbox
CONCAT output, "LOCAL result: "+#local_block(t1,2)+"\n"

CONCAT output, "LABEL result: "+#label_block(t1,2)+"\n"

TEXTBOX output
LOOP target, count
Parameters:

target: the name of a label or local label in the current script
count: expression of type LONGWORD

more...

less...

LOOP calls the subroutine marked with the label target count times. During subroutine execution, the current loop index can be retrieved by reading the special variable LOOP.

Contrary to the CALL command, no additional parameters can be passed to the subroutine. Use the PUSH command to store parameters on the stack.
See also: LOCAL...ENDLOCAL, LOOP special variable, CALL, RETURN.
Sample:
= factorial function
INCLUDE 'def.mps'
OPTION GLOBALVARS, 1
LET NUMBER_RADIX = 10
LET NUMBER_PREFIX = ''
LET NUMBER_SUFFIX = ''

VAR b BYTE
VAR res SIGQWORD

LABEL start
LET b = BYTE(INPUT('Factorial function', 'Enter a number between 1 and 20'))
IF (b < 1) OR (b > 20): GOTO start: ENDIF

LET res = 0
LOOP factorial, (b+1)

MSGBOX ('!'+TEXT(b)+' = '+TEXT(res)), MB_ICONASTERISK, 'Factorial function'
END

LABEL factorial
IF loop == 0
  LET res = 1
ELSE
  LET res = res * loop
ENDIF
RETURN
MSGBOX message [, flags [, title]]
Parameters:

message: expression of type TEXT
flags: optional expression of type LONGWORD
title: optional expression of type TEXT

more...

less...

MSGBOX shows a dialog displaying the text message.

The optional flags parameter tells Windows to change the behaviour and/or appearance of the dialog (see MSGBOX flags). If you want to show a message box containing more than one button, you should use the MSGBOX() function to retrieve the button clicked by the user.

The optional title parameter modifies the title bar caption of the message dialog.
See also: TEXTBOX, MSGBOX() function.
Sample:
INCLUDE 'def.mps'

= show an info message
MSGBOX 'Info message', MB_ICONINFORMATION

= show a warning message using a different title
MSGBOX 'Warning message', MB_ICONWARNING, 'Warning title'

= show an error message with 'yes' and 'no' buttons
MSGBOX 'Error message', (MB_ICONERROR OR MB_YESNO)
OPTION statement (see Directives)
POP var
Parameters:

var: a variable

more...

less...

POP returns a data stored on the stack and assigns it to the variable var. The data is removed from the stack. The data type depends on the data on the stack and can be retrieved using the TYPEOFSTACK special variable. Data can be pushed to the stack using the CALL and PUSH commands and the CALL() function.

In Tiny Hexer Script, the stack is a LIFO (last in first out), so when pushing the text "A" first and after this the numeric value 200 to the stack, POP returns 200 on the first and "A" on the second call. The stack can hold up to 4095 data values at a time.
See also: CALL, CALL(), PUSH, TYPEOFSTACK.
Sample:
VAR t1 TEXT,  t2 TEXT

= pushes 'first', than 'second' to the stack and calls the label concat
CALL concat, "first", "second"

= use the END command to avoid running into the subroutine again
END

LABEL concat
POP t1
= t1 now contains 'second' (the last parameter pushed to the stack)

POP t2
= t2 now contains 'first' (the last-but-one parameter pushed to the stack)

= displays the message 'second first' !!!
MSGBOX t1+" "+t2

= return from the subroutine
RETURN
PUSH param1 [, param2...]
Parameters:

param1/2...: expressions

more...

less...

PUSH stores all its parameters param1/2... to the stack. To restore data pushed to the stack, use the POP command.

In Tiny Hexer Script, the stack is a LIFO (last in first out), so when pushing the text "A" first and after this the numeric value 200 to the stack, POP returns 200 on the first and "A" on the second call. The stack can hold up to 4095 data values at a time.
See also: POP.
Sample:
= exchange vars example
VAR t1 TEXT,  t2 TEXT

t1 = 'first'
t2 = 'second'

= now exchange the two variables using the stack as temporary storage
PUSH t1, t2
POP t1
POP t2

= t1 now contains the text 'second', t2 now contains the text 'first'
REGWRITE key [, name [,value]]
Parameters:

key, name: TEXT expressions
value: an expression

more...

less...

Use the REGWRITE command to write data to the registry.

key is the name of the registry key. by default, REGWRITE sets values in the HKEY_CURRENT_USER root key. to select another root key, prefix key by the name of the root key (e.g. 'HKEY_LOCAL_MACHINE\Software...').

Note: To write data to Tiny Hexer's settings database rather than to the registry, use the 'HKEY_SETTINGS' pseudo root key.

name is the name of the value in the given registry key.
value is the actual data to be stored in the registry.

If name and value are omitted, the whole key key is removed from the registry.

If value is omitted, the data name is removed from the key key in the registry.
See also: REGREAD() function, INIWRITE command.
Sample:
DEF reg "HKEY_CURRENT_USER\\Temporary Test Key"

= write some data to the registry
regwrite reg, "name1", 2
regwrite reg, "name2", "abc"

VAR val LONGWORD val_t TEXT

= try to read name1 as LONGWORD
IF REGREAD(reg, "name1", @val)
  MSGBOX ('Value of name1: '+TEXT(val))
ELSE
  ERROR ('Cannot read name1 value from '+reg)
ENDIF

= try to read name2 as text
IF REGREAD(reg, "name2", @val_t)
  MSGBOX ('Value of name2: '+val_t)
ELSE
  ERROR ('Cannot read name2 value from '+reg)
ENDIF

= delete temporary key
regwrite reg
REPEAT : block : UNTIL condition
Parameters:

block: a sequence of Tiny Hexer Script commands
condition: a numeric expression

more...

less...

REPEAT...UNTIL commands are used to execute a sequence of commands (block) as long as the numeric expression condition equals to 0.

Contrary to the WHILE...ENDWHILE command, the block command sequence is always executed at least once.
See also: IF...ELSE...ENDIF, WHILE...ENDWHILE.
Sample:
INCLUDE 'def.mps'

VAR button LONGWORD

= enter the loop
REPEAT
  button = MSGBOX('Leave this loop?', MB_YESNO or MB_ICONQUESTION or MB_DEFBUTTON2)

  = leave the loop only if the user clicked the IDYES button
UNTIL button == IDYES
RETURN [return_value]
Parameters:

return_value: an expression

more...

less...

Use the RETURN command to end a subroutine executed by CALL, CALL() or LOOP and return to the command following the calling.

If the subroutine has been executed by the CALL() function, a value return_value can be returned to the calling expression.
See also: CALL, CALL(), LOOP, OPTION GLOBALVARS directive.
Sample:
MSGBOX "Main block"

CALL Sub1
MSGBOX CALL("Sub2")
MSGBOX "Main block again"
END

@@Sub1
MSGBOX "Subroutine 1, called by the CALL command"
RETURN

@@Sub2
RETURN "Subroutine 2, called by the CALL() function"
SHELL program [, parameters [, show [, directory [, wait]]]]
Parameters:

program, parameters, directory: expressions of type TEXT
show: an expression of type LONGWORD
wait: an expression of type BYTE

more...

less...

The SHELL command is used to execute the external application program.

Optionally the command line arguments parameters can be passed to program.

Additionally you can tell Tiny Hexer Script to show or hide the external application using the show parameter (SW_HIDE, SW_SHOW...)

The optional directory parameter tells Windows to set program's current directory.

The optional wait flag tells Tiny Hexer Script whether to wait until the external program has finished (1) or not (0, this is the default).
See also: SHELL() function.
Sample:
= open autoexec.bat in editor in maximized state
INCLUDE 'def.mps'

SHELL 'Notepad.exe', 'c:\autoexec.bat', SW_SHOWMAXIMIZED
SHOWPROGRESS
SHOWPROGRESS percentage
SHOWPROGRESS max, current
Parameters:

percentage: an expression of type BYTE
max, current: expressions of type LONGWORD

more...

less...

The SHOWPROGRESS command is used to control the progress indicator on the status bar of Tiny Hexer's main window.

SHOWPROGRESS without parameters hides the progress indicator.

SHOWPROGRESS percentage sets the progress indicator to the value percentage (0..100). A value greater than 99 hides the progress indicator.

SHOWPROGRESS max, current lets Tiny Hexer calculate the percentage itself. If current is equal to or greater than max (percentage >= 100), the progress indicator is hidden.
Sample:
= show a progress value of 50 percent
SHOWPROGRESS 50
MSGBOX "50% progress"

= show a progress of 75 percent (150/200 = 0.75)
SHOWPROGRESS 200, 150
MSGBOX "75% progress ((150 / 200) * 100)"

= hide the progress bar
SHOWPROGRESS
TAGVAR var, [tag_pos], [tag_len]
Parameters:

var: a variable
tag_pos, tag_len: expressions of type LONGWORD

more...

less...

Use the TAGVAR command to set, modify or remove tags of variables. Tagged variables are used in the Structure Viewer to display hyperlinks in the browser window.

If either the tag_pos or the tag_len parameter is empty, the corresponding tag part of var remains unchanged.

If both tag_pos and tag_len are empty, var is untagged.
See also: Variable tagging, COPYTAGS, TAG_POS() function, TAG_LEN() function, OPTION READTAGS directive.
Sample:
= TAGVAR example:
=
= display a hyperlink in the browser window that selects the first 7 bytes in the
= current editor
=
= NOTE: This sample script must be loaded into the structure viewer!

VAR browser FILE

= open a file to the browser structview browser window to write the data
browser = FILEOPEN('::browser','c')

VAR hyper TEXT

LET hyper = "Select the first seven bytes in the current editor.\n\n"

= 0: position of link-block
= 7: length of link-block
TAGVAR hyper, 0, 7

FILEWRITE browser, hyper

LET hyper = "This text is not a hyperlink."

= untag the variable
TAGVAR hyper, ,

FILEWRITE browser, hyper

= close the browser file
FILECLOSE browser
TEXTBOX text [, title]
Parameters:

text, title: expressions of type TEXT

more...

less...

The TEXTBOX command is used to display a (multiline) text in a modal window. This text can be copied to the clipboard and/or saved to disk.

text is the text to display.

title is the optional caption of the message window's title bar. If this parameter is omitted, a default title is used.
See also: MSGBOX.
Sample:
= TEXTBOX example:
=
= read the directory C:\ via the shell and show the dir list
= using the TEXTBOX command

VAR msg TEXT

IF (SHELL(ENVPARSE('%comspec%'), '/k DIR', 0, 'C:\', @msg) != 0)
  ERROR "Cannot execute shell"
ENDIF

TEXTBOX msg, "Directory List"
VAR name type [, name type...]
Parameters:

name: name of the variable to be declared
type: type of the variable to be declared

more...

less...

The VAR command declares the variable name and tells Tiny Hexer Script its data type.

variables can be declared only once, they must be declared before other commands can use them.
See also: Variables, Data types, OPTION GLOBALVARS directive.
Sample:
= declare a text and a number (Byte) variable
VAR msg TEXT, num BYTE

= assign a value
LET msg = 'Hello'

= show message
MSGBOX msg

= the following does not work as num is not of type text
LET num = 'Hello'
WHILE condition : block : ENDWHILE
Parameters:

condition: a numeric expression
block: a sequence of Tiny Hexer Script commands

more...

less...

WHILE...ENDWHILE commands are used to execute a sequence of commands (block) as long as the numeric expression condition does not equal to 0.

Contrary to the REPEAT...UNTIL command, the block command is not executed at all if condition equals to 0.
See also: IF...ELSE...ENDIF, REPEAT...UNTIL.
Sample:
= the command between WHILE...ENDWHILE will never be executed
WHILE 0 == 1
  MSGBOX 'This message will never be shown!'
ENDWHILE

===============================================

VAR num BYTE
LET num = 0
WHILE num != 8
  INC num, 1
ENDWHILE

MSGBOX ("Number is: "+TEXT(num))


Tiny Hexer Script: Functions

This page shows all available Tiny Hexer Script functions. Note: As of version 1.6.0.2 of Tiny Hexer most functions can be used like commands, i. e. functions which have no equally named command counterpart can be used as first keyword in a script line (in this case the function's result is discarded).
# A B C D E F G H I L M O P R S T W
NUMBER ABS(number)*
Parameters:

number: a numeric expression

more...

less...

ABS() returns the absolute value of the argument number
Sample:
VAR float DOUBLE integer SIGWORD

float   = ABS(-2.5):=  returns 2.5
integer = ABS(-4711):= returns 4711

MSGBOX (TEXT(float)+', '+DEC(integer))
EXTENDED ARCCOS(number)*
Parameters:

number: a floating point expression

more...

less...

ARCCOS() returns the arcus cosine of the argument number (range -1..1). The result is in the range 0..PI.
EXTENDED ARCSIN(number)*
Parameters:

number: a floating point expression

more...

less...

ARCSIN() returns the arcus sine of the argument number (range -1..1). The result is in the range -PI//2..PI//2.
EXTENDED ARCTAN(number)*
Parameters:

number: a floating point expression

more...

less...

ARCTAN() returns the arcus tangent of the argument number. The result is in the range -PI//2..PI//2.
TEXT ASKDIRECTORY([title [, selection]])*
Parameters:

title, selection: optional TEXT expressions

more...

less...

Use the ASKDIRECTORY() function to let the user select a directory from a dialog.

The optional title parameter sets the title of the directory selection dialog.

The optional selection parameter tells Tiny Hexer which directory should be selected when the dialog is shown (on some versions of Windows this will not work).

Note: If the user chooses the "Cancel" button in the directory selection dialog, the script will be terminated if no error handler is set.
See also: ASKOPENFILENAME(), ASKSAVEFILENAME().
Sample:
= select a directory and display it in a message box
VAR dir TEXT

LET dir = ASKDIRECTORY('Please choose a directory', 'c:\')

MSGBOX ('You selected the directory '+dir)
BYTE ASKFINDOPTIONS(caption, searchdata_ref, istext_ref, ignorecase_ref, wildcard_ref)*
Parameters:

caption: a TEXT expression
searchdata_ref, istext_ref, ignorecase_ref, wildcard_ref: expressions of type VARREF

more...

less...

Use the ASKFINDOPTIONS() function to let the user choose search options in a find dialog.

If the User clicks the Cancel button, the function returns 0, otherwise 1 is returned and the find options are stored in the variables referenced by the *_ref expressions:

searchdata_ref must refer to a TEXT variable that will be set to the text to search for.

istext_ref must refer to a BYTE variable set to the value of the "Find Text" and "Regular Expression" checkboxes (2 if "Regular Expression" is checked, 1 if "Find Text" is checked, 0 otherwise).

ignorecase_ref must refer to a BYTE variable set to the value of the "Ignore Case" checkbox.

wildcard_ref must refer to a TEXT variable that is set to the wildcard text if the user checked the "Wildcard" checkbox, otherwise, it's set to an empty string.
Sample:
= search for all occurences of a string in the current file, store
= the results in the position list and save the positions list to disk

= query find options
var f_Text TEXT, f_FindText BYTE, f_IgnoreCase BYTE, f_Wildcard TEXT
if (not AskFindOptions("Search the whole file and save results", @f_Text, @f_FindText, @f_IgnoreCase, @f_Wildcard))
  end
endif

= query file name for list saving
var res_file TEXT
res_file = AskSaveFileName("Choose name of search results file", 'Text Files (*.txt)|*.txt')

= clear current contents of the position list
if (POSITION_COUNT)
  !CMD.PosList.PosListSelectAll
  !CMD.PosList.PosListDeleteSelected
endif

= find all and store in the position list
!CMD.EditFindStore f_text, f_ignorecase, f_findtext, f_wildcard

if (not POSITION_COUNT)
  = not found
  error "Data not found!"
else
  = save
  POSITION_DESC = ("Search results for: "+f_text+" on "+CURRENTFILE)
  !CMD.PosList.PosListSave res_file
endif
TEXT ASKOPENFILENAME([caption [, filter [, default ]]])*
Parameters:

caption, filter, default: optional TEXT expressions

more...

less...

Use the ASKOPENFILENAME() function to let the user select a filename for file loading.

The optional caption parameter sets the title of the file selection dialog.

The optional filter parameter tells Tiny Hexer what file types to display in the file selection dialog. This parameter is a TEXT string in the form of "Description|File mask[|...]" (e.g. "Text files|*.txt|All files|*.*").

The optional default parameter tells Tiny Hexer the initial filename to be used when displaying the dialog.

Note: If the user chooses the "Cancel" button in the file dialog, the script will be terminated if no error handler is set.
See also: ASKDIRECTORY(), ASKSAVEFILENAME().
Sample:
= select a file and print it via notepad
VAR fname TEXT

LET fname = ASKOPENFILENAME('Print a Text file', 'Text Files (*.txt)|*.txt')

SHELL 'notepad.exe',  ('/p "'+fname+'"')
TEXT ASKSAVEFILENAME([caption [, filter [, defext [, default ]]]])*
Parameters:

caption, filter, defext, default: optional TEXT expressions

more...

less...

Use the ASKSAVEFILENAME() function to let the user select a filename for file storing.

The optional caption parameter sets the title of the file selection dialog.

The optional filter parameter tells Tiny Hexer what file types to display in the file selection dialog. This parameter is a TEXT string in the form of "Description|File mask[|...]" (e.g. "Text files|*.txt|All files|*.*").

The optional defext parameter tells Tiny Hexer which filename extension to use if none is entered in the dialog.

The optional default parameter tells Tiny Hexer the initial filename to be used when displaying the dialog.

Note: If the user chooses the "Cancel" button in the file dialog, the script will be terminated if no error handler is set.
See also: ASKDIRECTORY(), ASKOPENFILENAME().
Sample:
= save the current selection to disk
VAR selname TEXT

IF CURRENTFILE == ''
  ERROR 'No open file'
ENDIF

LET selname = ASKSAVEFILENAME('Save current selection', 'All Files (*.*)|*.*')

!CMD.FileSaveSelection selname
TEXT BIN(number [, usetype])
Parameters:

number: an ordinal expression
usetype: an optional expression of type BYTE

more...

less...

Use the BIN() function to convert the ordinal numeric expression number to a binary representation consisting of the characters "0" and "1". If the optional parameter usetype is set to 0, numbers < 0 are always converted as 64 bits signed values. If set to 1, the type of number is used to convert negative values. This flag affects the converted representation of negative values only, positive values are always calculated using the original data type.
See also: DEC(), HEX(), OCT().
Sample:
MSGBOX (BIN(BYTE(1))):= shows "00000001" (8 bits)
MSGBOX (BIN(WORD(256))):= shows "0000000100000000" (16 bits)
MSGBOX (BIN(LONGWORD(256))):= shows "00000000000000000000000100000000" (32 bits)
MSGBOX (BIN(SIGBYTE(-1))):= shows "1111111111111111111111111111111111111111111111111111111111111111" (64 bits)
MSGBOX (BIN(SIGBYTE(-1),1)):= shows "11111111" (8 bits)
MSGBOX (BIN(SIGWORD(-1),1)):= shows "1111111111111111" (16 bits)
TEXT BIN2HEX(strdata [, swaphalfbytes])
Parameters:

strdata: an expression of type TEXT
swaphalfbytes: an optional expression of type BYTE

more...

less...

The BIN2HEX() function is used to convert the binary contents of the expression strdata to their hexadecimal text representation, i.e. each byte is converted to two hexadecimal digits.

If the optional paramater swaphalfbytes is set to 1, the order of the returned values is <low halfbyte><high halfbyte>..., otherwise the order is <high halfbyte><low halfbyte>...
See also: HEX2BIN().
Sample:
= convert data to hexadecimal digits
VAR txt1 TEXT txt2 TEXT

txt1 = 'ABC'

LET txt2 = BIN2HEX(txt1)
= txt2 now contains '414243'

MSGBOX txt2

LET txt2 = BIN2HEX(txt1, 1)
= txt2 now contains '142434'

MSGBOX txt2
BYTE BYTE(expr)
Parameters:

expr: an expression

more...

less...

The BYTE() function is used to convert the expression expr to the BYTE data type.

If expr is a numeric or CHAR expression, the lowest eight bits of its ordinal value are returned.

If expr is of type TEXT, Tiny Hexer tries to convert the text string to a number. If conversion fails, an error is raised. If conversion succeeds, the lowest eight bits of the converted number are returned.
See also: Data types.
Sample:
= show the ascii value of a char
VAR ch CHAR inp TEXT bt BYTE

REPEAT
  inp = INPUT('Enter a character', '', 'A')
UNTIL TEXTLEN(inp) == 1

LET ch = inp

LET bt = BYTE(ch)

MSGBOX ('The ASCII value of '+inp+' is '+TEXT(bt))
LONGWORD BYTESTRING(text)
Parameters:

text: a textual expression

more...

less...

The BYTESTRING() function tries to convert the text text to a byte value.
Sample:
= convert some byte strings
VAR s1 TEXT s2 TEXT s3 TEXT
VAR res LONGWORD

LET s1 = "2.5 GB"
LET s2 = "512k"
LET s3 = "8 MEGABYTE"

LET res = BYTESTRING(s1)
= res contains the value 2.5 * 1024 * 1024 * 1024 = 2684354560
MSGBOX DEC(res)

LET res = BYTESTRING(s2)
= res contains the value 512 * 1024 = 524288
MSGBOX DEC(res)

LET res = BYTESTRING(s3)
= res contains the value 8 * 1024 * 1024 = 8388608
MSGBOX DEC(res)
VALUE CALL(target [, param1, param2...])
VALUE #target [( param1, param2...)]
Parameters:

target: the name of a label in the current script (in the form of a TEXT expression if the CALL() construct is used)
param1/2...: optional expressions that are pushed to the stack

more...

less...

The CALL() function is used to execute a user defined subroutine in the current script at the label target. The subroutine should return a value using the RETURN command. This value is used as the function's value. Contrary to the CALL command, the label's name must be specified using a textual expression, so the CALL() function is slower than the CALL command as the position of the label target is looked up from a table at runtime rather than at compile time. But the function is also more flexible as the label can be changed at runtime. Note: As of version 1.7 of Tiny Hexer, you can use the #target construct to avoid label name lookups at runtime. This construct can only be used with labels that are already defined.

The CALL() function can have optional parameters that are pushed to the stack. The subroutine can retrieve those parameters using the POP command. (Note: Because the stack is a LIFO, the first POP in a subroutine returns the last parameter, the second POP returns the last but one parameter...). The subroutine can retrieve the number of parameters pushed to the stack by reading the ARGC special variable.
See also: CALL, LABEL, LOCAL...ENDLOCAL,RETURN, ARGC special variable, POP, OPTION GLOBALVARS directive.
Sample:

= SAMPLE 1 = calculating the factorial using recursive function calls

= recursive factorial function
LOCAL factorial
  VAR fac SIGQWORD n SIGQWORD

  POP n
  fac = 1
  IF (n > 1)
    fac = n * #factorial(n-1)
  ENDIF
  RETURN fac
ENDLOCAL

VAR num BYTE

@@loop1
num=INPUTNUMBER('Factorial', 'Enter a number between 0 and 20:',20)
= 21! and above do not fit into 63 Bits
IF (num > 20):GOTO loop1:ENDIF

MSGBOX (DEC(num)+'! = '+DEC(#factorial(num)))
END

= SAMPLE 2 = showing the usage of CALL(), ARGC, TYPEOFSTACK, POP, RETURN

INCLUDE 'DEF.MPS'
OPTION GLOBALVARS, 0

= pop a value from the stack, ensure it is text
LOCAL poptext
  VAR result TEXT stacktype BYTE
  = get the type of the data on stack
  stacktype=TYPEOFSTACK:= store the stack data type in a local variable before using it in complex expressions!

  IF ((stacktype == SINGLE_DATA) OR (stacktype == COMP_DATA) OR (stacktype == DOUBLE_DATA)  OR (stacktype == EXTENDED_DATA))
    = handle floating point expressions
    VAR ftemp EXTENDED
    POP ftemp
    result = TEXT(ftemp)
  ELSE
    IF ((stacktype != CHAR_DATA) AND (stacktype != TEXT_DATA))
      = seems to be a number, so pop the number and convert to text
      VAR temp SIGQWORD
      POP temp
      result = DEC(temp)
    ELSE
      = is text, pop directly from stack
      POP result
    ENDIF
  ENDIF
  = return the data as text
  RETURN result
ENDLOCAL

LOCAL args
  VAR argt TEXT
  = check the number of parameters pushed to the stack by the caller
  IF ARGC > 0
    = pop the value from the stack, ensure it's of type TEXT
    argt = #poptext
    = pop remaining data to cleanup stack
    IF ARGC > 1
      LOOP poptext, ARGC-1
    ENDIF
  ENDIF
  RETURN (DEC(argc)+' arguments, last argument: '+argt)
ENDLOCAL

VAR t TEXT
t="I am variable t"
MSGBOX #args:= call the local sub 'args', no parameters
MSGBOX CALL('args','text'):= call the local sub 'args', one text parameter
MSGBOX #args('text',2):= call the local sub 'args', text and numeric parameter
MSGBOX #args('text',8,-3.98):= call the local sub 'args', text, ordinal and float parameter
MSGBOX CALL('args','text',2,'hey!',5.8,t):= call the local sub 'args', mixed parameters
SIGLONGWORD CEIL(number)*
Parameters:

number: a numeric expression

more...

less...

CEIL() returns the ordinal value of the argument number, rounded towards infinity.
See also: FLOOR(), FRAC(), INT(), ROUND(), TRUNC().
Sample:
MSGBOX (DEC(CEIL(2.0))):= results in "2"
MSGBOX (DEC(CEIL(2.0001))):= results in "3"
MSGBOX (DEC(CEIL(-2.0001))):= results in "-2"
CHAR CHAR(expr)
Parameters:

expr: an expression

more...

less...

The CHAR() function is used to convert the expression expr to the CHAR data type.

If expr is a numeric expression, the lowest eight bits of its ordinal value are converted to a character and are returned.

If expr is of type TEXT, the first character of the string is returned. If the string is empty, an error is raised.
See also: Data types.
Sample:
= show the character representing an ascii value
VAR ch CHAR num BYTE inp TEXT

REPEAT
  REPEAT
    inp = INPUT('Enter an ASCII value between 33 and 127', '', '65')
  UNTIL ISNUMBER(inp)
  LET num = BYTE(inp)
UNTIL (num > 32) AND (num < 128)

LET ch = CHAR(num)

MSGBOX ('Character: "'+ch+'"')
COMP COMP(expr)
Parameters:

expr: an expression

more...

less...

The COMP() function is used to convert the expression expr to the COMP data type.

If expr is a numeric or CHAR expression, its ordinal numeric value is returned.

If expr is of type TEXT, Tiny Hexer tries to convert the text string to a 64 bits signed number. If conversion fails, an error is raised.
See also: Data types.
Sample:
VAR inp TEXT co COMP

REPEAT
  inp = INPUT('Enter a number')
UNTIL ISNUMBER(inp)

LET co = COMP(inp)

MSGBOX ('The number you entered was: '+TEXT(co))
LONGWORD COMPARE_END(index)*
Parameters:

index: a numeric expression

more...

less...

The COMPARE_END() function returns the position of the last byte of difference block #index (first block is at index 0) after a file comparison has been executed.
See also: File comparison, COMPARE_COUNT special variable, COMPARE_START().
LONGWORD COMPARE_START(index)*
Parameters:

index: a numeric expression

more...

less...

The COMPARE_START() function returns the position of the first byte of difference block #index (first block is at index 0) after a file comparison has been executed.
See also: File comparison, COMPARE_COUNT special variable, COMPARE_END().
EXTENDED COS(number)*
Parameters:

number: a floating point expression

more...

less...

COS() returns the cosine of the argument number (radian).
EXTENDED COT(number)*
Parameters:

number: a floating point expression

more...

less...

COT() returns the cotangent of the argument number (radian).
TEXT DATA2TEXT(expr)
Parameters:

expr: an expression

more...

less...

The DATA2TEXT() function is used to store the binary value of expression expr in a data of type TEXT.

It e.g. can be used to create tables of multiple numeric values by storing them in a single TEXT string.
See also: TEXT2DATA(), DATA2TEXTBE().
Sample:
= power of 2 table example
INCLUDE 'def.mps'
OPTION GLOBALVARS, 1

VAR ptable TEXT, num SIGQWORD

= store the next power of 2 as SIGQWORD in ptable
LOCAL create_table
  CONCAT ptable, DATA2TEXT(SIGQWORD(num))
  INC num, num
ENDLOCAL

VAR inp TEXT q SIGQWORD power SIGQWORD

LET num = 1
LET ptable = ''
LOOP create_table 63

REPEAT
  REPEAT
    REPEAT
      LET inp = INPUT('Enter a number between 0 and 62')
    UNTIL ISNUMBER(inp)
    LET q = SIGQWORD(inp)
  UNTIL (q < 63) AND (q >= 0)

  = power values are stored as SIGQWORD, so SIGQWORD_SIZE must be used
  = to access the correct data
  power = TEXT2DATA(ptable, q, SIGQWORD_SIZE)
  MSGBOX ( '2 ** '+DEC(q)+' = '+DEC(power))

UNTIL 0
TEXT DATA2TEXTBE(expr)
Parameters:

expr: an expression

more...

less...

The DATA2TEXTBE() function is used to store the binary value of expression expr in a data of type TEXT in BIG ENDIAN format (used e.g. by Motorola CPUs).

It e.g. can be used to create tables of multiple numeric values by storing them in a single TEXT string.
See also: TEXT2DATABE(), DATA2TEXT().
Sample:
= power of 2 table example
INCLUDE 'def.mps'
OPTION GLOBALVARS, 1

VAR ptable TEXT, num SIGQWORD

= store the next power of 2 as SIGQWORD in ptable
LOCAL create_table
  CONCAT ptable, DATA2TEXTBE(SIGQWORD(num))
  INC num, num
ENDLOCAL

VAR inp TEXT q SIGQWORD power SIGQWORD

LET num = 1
LET ptable = ''
LOOP create_table 63

REPEAT
  REPEAT
    REPEAT
      LET inp = INPUT('Enter a number between 0 and 62')
    UNTIL ISNUMBER(inp)
    LET q = SIGQWORD(inp)
  UNTIL (q < 63) AND (q >= 0)

  = power values are stored as SIGQWORD, so SIGQWORD_SIZE must be used
  = to access the correct data
  power = TEXT2DATABE(ptable, q, SIGQWORD_SIZE)
  MSGBOX ( '2 ** '+DEC(q)+' = '+DEC(power))

UNTIL 0
TEXT DEC(number)
Parameters:

number: an ordinal expression

more...

less...

Use the DEC() function to convert the ordinal numeric expression number to a textual decimal representation consisting of the characters "0".."9". Numbers < 0 are prefixed by a "-" (minus) sign.
See also: BIN(), HEX(), OCT().
Sample:
MSGBOX (DEC(BYTE(1))):= shows "1" (8 bits)
MSGBOX (DEC(WORD(256))):= shows "256" (16 bits)
MSGBOX (DEC(LONGWORD(256))):= shows "256" (32 bits, but msbs set to 0)
MSGBOX (DEC(SIGBYTE(-1))):= shows "-1" (8 bits)
MSGBOX (DEC(SIGWORD(-1))):= also shows "-1" (16 bits)
MSGBOX (DEC(LONGWORD(-1))):= shows "4294967295" (32 bits, unsigned)
VAR DEREF(reference)
Parameters:

reference: a variable of type VARREF

more...

less...

The DEREF() function is used to retrieve the referenced variable stored in reference.

The function is used to e.g. pass data of arbitrary data types to a subroutine. To create references to variables, use the unary reference operator @.
See also: VARREF data type, unary reference operator @, TYPEOF().
Sample:
= show data type example
INCLUDE 'def.mps'
OPTION GLOBALVARS, 1

VAR output TEXT

= get a textual data type representation
LOCAL getdatatype
  VAR stack VARREF
  VAR type SIGBYTE
  VAR types TEXT
  LET types = <<
none
character
unsigned byte
unsigned word
unsigned long
signed quad
text
file
variable reference
single float
double float
extended float
comp float
signed byte
signed word
signed long
>>

  POP stack
  LET type = TYPEOF(DEREF(stack))
  IF ((type <= SIGLONGWORD_DATA) AND (type >= 0))
    RETURN TEXTLINE(types, type)
  ENDIF
  RETURN "unknown"

ENDLOCAL

LOCAL sub_tp
  VAR msg TEXT varn TEXT
  LET msg = #getdatatype
  POP varn
  CONCAT output, (varn+" is of type "+msg+"\n")
ENDLOCAL

VAR charV CHAR, byteV BYTE, wordV WORD, longwordV LONGWORD
VAR sigqwordV SIGQWORD, textV TEXT, fileV FILE, refV VARREF, noneV NONE
VAR singleV SINGLE, doubleV DOUBLE, extendedV EXTENDED, compV COMP
VAR sigbyteV SIGBYTE, sigwordV SIGWORD, siglongwordV SIGLONGWORD

call sub_tp, 'charV', @charV
call sub_tp, 'byteV', @byteV
call sub_tp, 'wordV', @wordV
call sub_tp, 'longwordV', @longwordV

call sub_tp, 'sigqwordV', @sigqwordV
call sub_tp, 'textV', @textV
call sub_tp, 'fileV', @fileV
call sub_tp, 'refV', @refV
call sub_tp, 'noneV', @noneV

call sub_tp, 'singleV', @singleV
call sub_tp, 'doubleV', @doubleV
call sub_tp, 'compV', @compV
call sub_tp, 'extendedV', @extendedV

call sub_tp, 'sigbyteV', @sigbyteV
call sub_tp, 'sigwordV', @sigwordV
call sub_tp, 'siglongwordV', @siglongwordV

TEXTBOX output
DOUBLE DOUBLE(expr)
Parameters:

expr: an expression

more...

less...

The DOUBLE() function is used to convert the expression expr to the DOUBLE precision floating point data type.

If expr is a numeric or CHAR expression, its numeric value is returned.

If expr is of type TEXT, Tiny Hexer tries to convert the text string to a floating point number. If conversion fails, an error is raised.
See also: Data types.
Sample:
VAR inp TEXT si SINGLE do DOUBLE ex EXTENDED

REPEAT
  inp = INPUT('Enter a floating point value')
UNTIL ISFLOAT(inp)

LET si = SINGLE(inp)
LET do = DOUBLE(inp)
LET ex = EXTENDED(inp)

MSGBOX ('The number you entered was (single precision): '+TEXT(si))
MSGBOX ('The number you entered was (double precision): '+TEXT(do))
MSGBOX ('The number you entered was (extended precision): '+TEXT(ex))
TEXT ENVPARSE(string)
Parameters:

string: an expression of type TEXT

more...

less...

The ENVPARSE() function expands all environment variables in string to their actual values. Environment variables must be enclosed in percent signs (%).

Three special variables do exist:
  • %APPPATH%: Expands to the name of the directory where Tiny Hexer resides
  • %DATE%: Expands to the current date
  • %TIME%: Expands to the current time
Sample:
= show current date and time
MSGBOX (ENVPARSE('Current Date: %date%, Current Time: %time%'))
TEXT ESCAPEHTML(string [, isunicode [, leaveblanks]])*
Parameters:

string: an expression of type TEXT
isunicode: optional expression of type BYTE
leaveblanks: optional expression of type BYTE

more...

less...

The ESCAPEHTML() function escapes all characters in string that have a special meaning/are not printeable in HTML. This function might be useful when printing characters like "<", ">" and so on to the structure viewer in raw mode.

If the optional parameter isunicode is set to 1, the text in string is treated as Unicode Little Endian text.
If the optional parameter leaveblanks is set to 1, blanks (0x20 chars) are not escaped to '&nbsp;', so they can lead to line breaks in the html document.
Sample:
INCLUDE 'def.mps'
= make some special characters html friendly
VAR s TEXT
s = ESCAPEHTML("<> &©")
= s now contains "&lt;&gt;&nbsp;&amp;&copy;"
MSGBOX s

= leave the blank unescaped
s = ESCAPEHTML("<> &©", 0, 1)
= s now contains "&lt;&gt; &amp;&copy;"
MSGBOX s

= now try the unicode version of the euro sign
VAR w TEXT
w = TEXTCONVERT("€", TEXTCONVERT_ANSI, TEXTCONVERT_UNICODE)
w = ESCAPEHTML(w, 1)
= w now contains "&euro;"
MSGBOX w
EXTENDED EXP(x)*
Parameters:

x: a floating point expression

more...

less...

EXP() returns the constant e raised to the power x.
EXTENDED EXTENDED(expr)
Parameters:

expr: an expression

more...

less...

The EXTENDED() function is used to convert the expression expr to the EXTENDED precision floating point data type.

If expr is a numeric or CHAR expression, its numeric value is returned.

If expr is of type TEXT, Tiny Hexer tries to convert the text string to a floating point number. If conversion fails, an error is raised.
See also: Data types.
Sample:
VAR inp TEXT si SINGLE do DOUBLE ex EXTENDED

REPEAT
  inp = INPUT('Enter a floating point value')
UNTIL ISFLOAT(inp)

LET si = SINGLE(inp)
LET do = DOUBLE(inp)
LET ex = EXTENDED(inp)

MSGBOX ('The number you entered was (single precision): '+TEXT(si))
MSGBOX ('The number you entered was (double precision): '+TEXT(do))
MSGBOX ('The number you entered was (extended precision): '+TEXT(ex))
TEXT EXTRACTNAME(name)
Parameters:

name: an expression of type TEXT

more...

less...

The EXTRACTNAME() function returns the filename part of name without the preceding path.
See also: EXTRACTPATH().
Sample:
VAR fname TEXT, fpath TEXT

LET fname = ASKOPENFILENAME('Select a file')
LET fpath = EXTRACTPATH(fname)
LET fname = EXTRACTNAME(fname)

MSGBOX ('The file '+fname+' is in directory '+fpath)
TEXT EXTRACTPATH(name)
Parameters:

name: an expression of type TEXT

more...

less...

The EXTRACTPATH() function returns the path part of name including the trailing backslash.
See also: EXTRACTNAME().
Sample:
VAR fname TEXT, fpath TEXT

LET fname = ASKOPENFILENAME('Select a file')
LET fpath = EXTRACTPATH(fname)
LET fname = EXTRACTNAME(fname)

MSGBOX ('The file '+fname+' is in directory '+fpath)
BYTE FILEEXISTS(filename)
Parameters:

filename: an expression of type TEXT

more...

less...

The FILEEXISTS() function returns 1 if the file filename exists, otherwise 0 is returned.
Sample:
VAR fname TEXT

LET fname = INPUT('Enter a filename to open in Tiny Hexer')

IF FILEEXISTS(fname)
  !CMD.FileOpen fname
ELSE
  ERROR ('File '+fname+' not found')
ENDIF
VALUE FILEGETPROP(file, property)
Parameters:

file: a variable of type FILE
property: an expression of type TEXT

more...

less...

FILEGETPROP() is used to retrieve a property of a special file.

The data type of the returned value depends on the property.

List of available properties

See also: FILESETPROP command, FILEOPEN().
Sample:
VAR ed FILE, val BYTE

= open the current editor window
LET ed = FILEOPEN('::current', 'r')

= get bytes per row
LET val = FILEGETPROP(ed, 'BytesPerRow')

= close the file
FILECLOSE ed

= show the BytesPerRow property
MSGBOX ('Current editor displays '+DEC(val)+' Bytes per row')
FILE FILEOPEN(filename, mode)
Parameters:

filename, mode: expressions of type TEXT

more...

less...

Use FILEOPEN() to attach file filename to a FILE type variable.

The mode parameter tells Tiny Hexer Script how to open the file and what access to grant to the file's contents. This parameter must be a combination of one or more of the following characters:
  • "c": always create the file, erase its contents if it already exists. This mode flag also implies write access to the file
  • "r": grant read access to the file's contents (default)
  • "w": grant write access to the file's contents
Special Files:
In Tiny Hexer there are numerous special files. To distinguish special files from ordinary files, the filename parameter must be start with a double colon "::". The following special files exist in Tiny Hexer:
  • "::Clipboard": open clipboard contents (CF_TEXT format by default, see also Clipboard property)
  • "::Browser": open the "Structure viewer" browser window, so you can write text to the browser. Note: The mode parameter must be set to "c". You cannot read from this file, and also random write access to this file is not possible, only sequential write access is supported
  • "::Buffer": creates an in-memory buffer for storing temporaray data. The file mode of such files is always set to READ/WRITE
  • "::New": open a new editor window and get access to this editor's data
  • "::Current": open a handle to the data of the currently active editor. If another editor window becomes active, the file remains attached to the editor which was active at the time the file has been opened
  • "::Editor": open a handle to the data of the currently active editor. If another editor window becoms active, the file will be attached to the newly activated editor.
  • "::<filename>": attaches the file to the editor data whose window caption matches <filename>
See also: FILECLOSE command, FILEREAD(), FILEWRITE().
Sample:
= sample: read a file from disk and write its contents to a new
= editor window, xoring each byte by 255
VAR ed FILE, f FILE, b BYTE sz LONGWORD lp LONGWORD

= open the file on disk (readonly "r")
LET f = FILEOPEN(ASKOPENFILENAME('Select a file'), 'r')

= open a new editor window
LET ed = FILEOPEN('::new', 'c')

LET sz = FILESIZE(f)
LET lp = 0

= set datasize of editor to file's size
FILESETPROP ed, 'Size', sz
= Changing the size sets the file pointer to eof, so reset
FILESEEK ed, 0

= read and transform the file's contents and write the data to the editor
WHILE FILEREAD(f, @b)
  SHOWPROGRESS sz, lp
  INC lp, 1
  LET b = b XOR 255
  FILEWRITE ed, b
ENDWHILE

= close the file handles
FILECLOSE ed
FILECLOSE f
LONGWORD FILEPOS(file)
Parameters:

file: file type variable

more...

less...

The FILEPOS() returns the current position pointer of file.
See also: FILESEEK command, FILEREAD(), FILESIZE(), FILEWRITE().
Sample:
INCLUDE 'def.mps'

VAR Position LONGWORD mpth FILE

= open tiny hexer itself in a new editor window
!CMD.FileOpen ENVPARSE('%apppath%\mpth.exe')

= attach a file to the editor, only read access is needed
mpth=FILEOPEN('::current', 'r')

Position=FILEPOS(mpth)

= show start position (0)
MSGBOX ("Position at start of file (= 0): "+DEC(Position)), (MB_OK OR MB_ICONINFORMATION)

= seek to file end
FILESEEK mpth, 0, FILE_END
= set cursor to end of file
!CMD.EditGoto '>0'

Position=FILEPOS(mpth)

= show end position (0)
MSGBOX ("Position at end of file (= file size): "+DEC(Position)), (MB_OK OR MB_ICONINFORMATION)
LONGWORD FILEREAD(file, buffer [, count])
Parameters:

file: a variable of type FILE
buffer: an expression of type VARREF
count: an optional expression of type LONGWORD

more...

less...

Use the FILEREAD() function to read data from the file file into the variable referenced by buffer.

The optional count parameter tells Tiny Hexer Script how many bytes of data are to be read. If this parameter is omitted, the type of the variable referenced by buffer defines the amount of data to be read (BYTE, CHAR: 1 Byte, WORD: 2 Bytes, LONGWORD: 4 Bytes, SIGQWORD: 8 Bytes, TEXT: reads from the file until EOF or a 0x00 byte is found).

FILEREAD() returns the actual amount of data (in Bytes) that was read from the file.
See also: FILEREAD command, FILEWRITE().
Sample:
VAR f FILE, wholefile TEXT, amount LONGWORD

= open the file c:\boot.ini for reading
LET f = FILEOPEN('c:\boot.ini', 'r')

= read up to 500000 bytes from the file
amount=FILEREAD(f, @wholefile, 500000)

= close the file handle
FILECLOSE f

= tell how many data has been read
MSGBOX ("Bytes read: "+DEC(amount))
LONGWORD FILEREADBE(file, buffer)
Parameters:

file: a variable of type FILE
buffer: an expression of type VARREF

more...

less...

Use the FILEREADBE() function to read data from the file file into the variable referenced by buffer if the file's contents are stored in BIG ENDIAN format (e.g. on Motorola CPUs).

The type of the variable referenced by buffer defines the amount of data to be read (BYTE, CHAR: 1 Byte, WORD: 2 Bytes, LONGWORD: 4 Bytes, SIGQWORD: 8 Bytes, TEXT: reads from the file until EOF or a 0x00 byte is found).

If the variable referenced by buffer is of type WORD, LONGWORD or SIGQWORD, the data is swapped after reading (e.g. LONGWORD = Byte 0 becomes Byte 3, Byte 1 becomes Byte 2, Byte 2 becomes Byte 1 and Byte 3 becomes Byte 0). On other data types, the function is similar to the FILEREAD() function (except for the missing count parameter).

FILEREADBE() returns the actual amount of data (in Bytes) that was read from the file.
See also: FILEREADBE command, FILEWRITEBE(), FILEREAD().
TEXT FILES(index)*
Parameters:

index: expression of type LONGWORD

more...

less...

The FILES() function returns the filename of the editor child #index (first file is at index 0). Use the FILE_COUNT special variable to get the number of files currently opened in Tiny Hexer.
See also: FILE_COUNT special variable.
Sample:
= enumerate all open editor files

VAR d LONGWORD
VAR ed TEXT

d=FILE_COUNT
IF d == 0
  MSGBOX "No files open"
ELSE
  LOOP enum d
ENDIF
END

@@enum
ed=FILES(loop)
MSGBOX ("File "+DEC(loop+1)+": "+ed)
RETURN
LONGWORD FILESIZE(file)
Parameters:

file: file type variable

more...

less...

The FILESIZE() returns the size (in Bytes) of file.
See also: FILESEEK command, FILEPOS().
Sample:
INCLUDE 'def.mps'

VAR Size LONGWORD mpth FILE

= open tiny hexer itself in a new editor window
!CMD.FileOpen ENVPARSE('%apppath%\mpth.exe')

= attach a file to the editor, only read access is needed
mpth=FILEOPEN('::current', 'r')

Size=FILESIZE(mpth)

MSGBOX ("Size of file: "+DEC(Size)), (MB_OK OR MB_ICONINFORMATION)
LONGWORD FILEWRITE(file, data)
Parameters:

file: a variable of type FILE
data: an expression of type TEXT, CHAR, BYTE, WORD, LONGWORD or SIGQWORD

more...

less...

Use the FILEWRITE() function to write the contents of data to the file file.

The type of the data expression defines the amount of data to be written to the file (BYTE, CHAR: 1 Byte, WORD: 2 Bytes, LONGWORD: 4 Bytes, SIGQWORD: 8 Bytes, TEXT: length of the text value).

FILEWRITE() returns the actual amount of data (in Bytes) that has been written.
See also: FILEWRITE command, FILEREAD().
Sample:
INCLUDE 'def.mps'

VAR f FILE, dw LONGWORD, written LONGWORD, fname TEXT l TEXT
LET fname = 'c:\test.dat'

= enter a number
REPEAT
  l = INPUT('Enter a number')
UNTIL ISNUMBER(l)
LET dw=LONGWORD(l)

= create the file
LET f = FILEOPEN(fname, 'c')

= write the number in binary format
LET written=FILEWRITE(f, dw)

= close the file handle
FILECLOSE f

= check if all data has been written
IF written != LONGWORD_SIZE
  ERROR "Not all data could be written!"
ENDIF
LONGWORD FILEWRITEBE(file, data)
Parameters:

file: a variable of type FILE
data: an expression of type TEXT, CHAR, BYTE, WORD, LONGWORD or SIGQWORD

more...

less...

Use the FILEWRITEBE() function to write the contents of data to the file file if the file's contents should be stored in BIG ENDIAN format (e.g. on Motorola CPUs).

The type of the data expression defines the amount of data to be written to the file (BYTE, CHAR: 1 Byte, WORD: 2 Bytes, LONGWORD: 4 Bytes, SIGQWORD: 8 Bytes, TEXT: length of the text value).

If data is of type WORD, LONGWORD or SIGQWORD, the data is swapped before writing (e.g. LONGWORD = Byte 0 becomes Byte 3, Byte 1 becomes Byte 2, Byte 2 becomes Byte 1 and Byte 3 becomes Byte 0). On other data types, the function is similar to the FILEWRITE() function.

FILEWRITEBE() returns the actual amount of data (in Bytes) that has been written.
See also: FILEWRITEBE command, FILEREADBE(), FILEWRITE().
SIGLONGWORD FLOATTOIBM4(float)*
Parameters:

float: a floating point expression

more...

less...

FLOATTOIBM4() converts the value of float into the ibm single precision floating point format. You cannot use the resulting SIGLONGWORD value for calculation but to store floating point values in ibm format in a file.
See also: FLOATTOIBM8(), IBM4TOFLOAT().
Sample:
VAR e EXTENDED

VAR i4 SIGLONGWORD i8 SIGQWORD:= variables to store ibm format floating point values

LET e = 1.23e-12
LET i4 = FLOATTOIBM4(e):= now i4 stores a ibm single floating point value
LET e = IBM4TOFLOAT(i4):= convert back (loses some precision due to single precision ibm format)
MSGBOX TEXT(e)

LET e = 1.23e-12
LET i8 = FLOATTOIBM8(e):= now i8 stores a ibm double floating point value
LET e = IBM8TOFLOAT(i8):= convert back (loses less precision due to double precision ibm format)
MSGBOX TEXT(e)
SIGQWORD FLOATTOIBM8(float)*
Parameters:

float: a floating point expression

more...

less...

FLOATTOIBM8() converts the value of float into the ibm double precision floating point format. You cannot use the resulting SIGQWORD value for calculation but to store floating point values in ibm format in a file.
See also: FLOATTOIBM4(), IBM8TOFLOAT().
Sample:
VAR e EXTENDED

VAR i4 SIGLONGWORD i8 SIGQWORD:= variables to store ibm format floating point values

LET e = 1.23e-12
LET i4 = FLOATTOIBM4(e):= now i4 stores a ibm single floating point value
LET e = IBM4TOFLOAT(i4):= convert back (loses some precision due to single precision ibm format)
MSGBOX TEXT(e)

LET e = 1.23e-12
LET i8 = FLOATTOIBM8(e):= now i8 stores a ibm double floating point value
LET e = IBM8TOFLOAT(i8):= convert back (loses less precision due to double precision ibm format)
MSGBOX TEXT(e)
SIGLONGWORD FLOOR(number)*
Parameters:

number: a numeric expression

more...

less...

FLOOR() returns the ordinal value of the argument number, rounded towards -infinity.
See also: CEIL(), FRAC(), INT(), ROUND(), TRUNC().
Sample:
MSGBOX (DEC(FLOOR(2.0))):= results in "2"
MSGBOX (DEC(FLOOR(2.9999))):= results in "2"
MSGBOX (DEC(FLOOR(-2.9999))):= results in "-3"
EXTENDED FRAC(number)*
Parameters:

number: a numeric expression

more...

less...

FRAC() returns the signed fractional part of the floating point value of number.
See also: CEIL(), FLOOR(), INT(), ROUND(), TRUNC().
Sample:
MSGBOX (TEXT(FRAC(2))):= results in "0"
MSGBOX (TEXT(FRAC(2.9999))):= results in "0.9999"
MSGBOX (TEXT(FRAC(-2.9999))):= results in "-0.9999"
GUI functions for user defined dialogs
GUI functions are described on a separate page
TEXT HEX(number [, usetype])
Parameters:

number: an ordinal expression
usetype: an optional expression of type BYTE

more...

less...

Use the HEX() function to convert the ordinal numeric expression number to a hexadecimal representation consisting of the characters "0".."9" and "A".."F". If the optional parameter usetype is set to 0, numbers < 0 are always converted as 64 bits signed values. If set to 1, the type of number is used to convert negative values. This flag affects the converted representation of negative values only, positive values are always calculated using the original data type.
See also: BIN(), DEC(), OCT().
Sample:
MSGBOX (HEX(BYTE(1))):= shows "01" (8 bits)
MSGBOX (HEX(WORD(256))):= shows "0100" (16 bits)
MSGBOX (HEX(LONGWORD(256))):= shows "00000100" (32 bits)
MSGBOX (HEX(SIGBYTE(-1))):= shows "FFFFFFFFFFFFFFFF" (64 bits)
MSGBOX (HEX(SIGBYTE(-1),1)):= shows "FF" (8 bits)
MSGBOX (HEX(SIGWORD(-1),1)):= shows "FFFF" (16 bits)
TEXT HEX2BIN(strhex [, swaphalfbytes])
Parameters:

strhex: an expression of type TEXT
swaphalfbytes: an optional expression of type BYTE

more...

less...

The HEX2BIN() function is used to convert a hexadecimal data representation in strhex to binary data. Characters in strhex that are no hexadecimal digits are skipped.

If the optional paramater swaphalfbytes is set to 1, the order of the hexadecimal digits is <low halfbyte><high halfbyte>..., otherwise the order is <high halfbyte><low halfbyte>...
See also: BIN2HEX().
Sample:
= convert hexadecimal digits to data
VAR txt1 TEXT txt2 TEXT

txt1 = '42 43 45'

LET txt2 = HEX2BIN(txt1)
= txt2 now contains 'BCE'

MSGBOX txt2

LET txt2 = HEX2BIN(txt1, 1)
= txt2 now contains '$4T'

MSGBOX txt2
SIGQWORD HEX2NUM(digits)
Parameters:

digits: an expression of type TEXT

more...

less...

The HEX2NUM() function is used to convert the TEXT expression digits (consisting of hexadecimal digits) to a number.
See also: ISHEX().
Sample:
VAR i SIGQWORD

LET i=HEX2NUM('FCE2')

= i is 64738 now
MSGBOX DEC(i)
EXTENDED IBM4TOFLOAT(ibm4val)*
Parameters:

ibm4val: a SIGLONGWORD

more...

less...

IBM4TOFLOAT() converts the value of the ibm single precision float format value stored in the ibm4val pseudo SIGLONGWORD into an extended IEEE floating point value.
See also: FLOATTOIBM4(), IBM8TOFLOAT().
Sample:
VAR e EXTENDED

VAR i4 SIGLONGWORD i8 SIGQWORD:= variables to store ibm format floating point values

LET e = 1.23e-12
LET i4 = FLOATTOIBM4(e):= now i4 stores a ibm single floating point value
LET e = IBM4TOFLOAT(i4):= convert back (loses some precision due to single precision ibm format)
MSGBOX TEXT(e)

LET e = 1.23e-12
LET i8 = FLOATTOIBM8(e):= now i8 stores a ibm double floating point value
LET e = IBM8TOFLOAT(i8):= convert back (loses less precision due to double precision ibm format)
MSGBOX TEXT(e)
EXTENDED IBM8TOFLOAT(ibm8val)*
Parameters:

ibm8val: a SIGQWORD

more...

less...

IBM8TOFLOAT() converts the value of the ibm double precision float format value stored in the ibm4val pseudo SIGQWORD into an extended IEEE floating point value.
See also: FLOATTOIBM8(), IBM4TOFLOAT().
Sample:
VAR e EXTENDED

VAR i4 SIGLONGWORD i8 SIGQWORD:= variables to store ibm format floating point values

LET e = 1.23e-12
LET i4 = FLOATTOIBM4(e):= now i4 stores a ibm single floating point value
LET e = IBM4TOFLOAT(i4):= convert back (loses some precision due to single precision ibm format)
MSGBOX TEXT(e)

LET e = 1.23e-12
LET i8 = FLOATTOIBM8(e):= now i8 stores a ibm double floating point value
LET e = IBM8TOFLOAT(i8):= convert back (loses less precision due to double precision ibm format)
MSGBOX TEXT(e)
BYTE INIREAD(filename, section, key, buffer)
Parameters:

filename, section, key: expressions of type TEXT
buffer: VARREF

more...

less...

Use the INIREAD() function to read values from ini-style text files.

filename is the name of the ini file.
section is the name of the section in the ini file ([section] lines).
key is the name of the key in the ini file (the part to the left of the equal sign).
buffer is a reference to a variable that will contain the value read from the ini file.

If the specified key could be read from the ini file, 1 is returned. Otherwise 0 is returned.
See also: INIWRITE command, REGREAD() function.
Sample:
DEF ini "d:\\mpthtest.ini"

= write some data to the ini file
iniwrite ini, "section1", "key1", 2
iniwrite ini, "section2", "key2", "abc"

VAR val LONGWORD val_t TEXT

= try to read section1/key1 as longword
IF INIREAD(ini, "section1", "key1", @val)
  MSGBOX ('Value of section1/key1: '+DEC(val))
ELSE
  ERROR ('Cannot read section1/key1 value from '+ini)
ENDIF

= try to read section2/key2 as text
IF INIREAD(ini, "section2", "key2", @val_t)
  MSGBOX ('Value of section2/key2: '+val_t)
ELSE
  ERROR ('Cannot read section2/key2 value from '+ini)
ENDIF
TEXT INPUT(prompt)
TEXT INPUT(caption, prompt [,default])*
Parameters:

caption, prompt, default: expressions of type TEXT

more...

less...

The INPUT() function is used to bring up an input dialog box ready for the user to enter a TEXT string in its edit box. INPUT() returns the value entered by the user.

caption is the title of the dialog box. If omitted, a default is used.

prompt is the text that prompts the user to enter a string in the edit box.

default is the string that appears in the edit box when the dialog box is displayed. If omitted, the edit box is empty.

Note: If the user chooses the "Cancel" button in the input dialog, the script will be terminated if no error handler is set.
See also: INPUTNUMBER().
Sample:
VAR forename TEXT, surname TEXT

LET forename=INPUT('Please enter your first name')
LET surname=INPUT('Surname', 'Please enter your last name')

MSGBOX ("Hello, "+forename+' '+surname+'!')
SIGQWORD INPUTNUMBER(prompt)
SIGQWORD INPUTNUMBER(caption, prompt [,default])*
Parameters:

caption, prompt: expressions of type TEXT
default: an expression of type SIGQWORD

more...

less...

The INPUTNUMBER() function is used to bring up a numeric input dialog box ready for the user to enter an ordinal (integral) number in its edit box in binary, octal, decimal or hexadecimal format. INPUTNUMBER() returns the value entered by the user. The edit box has an additional button to bring up a popup calculator.

caption is the title of the dialog box. If omitted, a default is used.

prompt is the text that prompts the user to enter a string in the edit box.

default is the number that appears in the edit box when the dialog box is displayed. If omitted, the edit box is set to zero.

Note: If the user chooses the "Cancel" button in the numeric input dialog, the script will be terminated if no error handler is set.
See also: INPUT().
Sample:
VAR addend1 SIGQWORD, addend2 SIGQWORD

LET addend1=INPUTNUMBER('Addition','Please enter addend 1')
LET addend2=INPUTNUMBER('Addition','Please enter addend 2')

MSGBOX ("The sum of "+DEC(addend1)+" and "+DEC(addend2)+" is "+DEC(addend1+addend2))
EXTENDED INT(number)*
Parameters:

number: a numeric expression

more...

less...

INT() returns the signed integral part of the floating point value of number, that is the fractional part is stripped off.
See also: CEIL(), FLOOR(), FRAC(), ROUND(), TRUNC().
Sample:
MSGBOX (TEXT(INT(2.005))):= results in "2"
MSGBOX (TEXT(INT(2.9999))):= results in "2"
MSGBOX (TEXT(INT(-2.9999))):= results in "-2"
BYTE ISFLOAT(value)
Parameters:

value: an expression of type TEXT

more...

less...

Use the ISFLOAT() function to determine whether the TEXT value is a valid floating point number representation (that is value solely consists of decimal digits and optionally decimal comma, minus sign and exponential sign ("E"). If value is a valid floating point number, 1 is returned, otherwise 0 is returned.
See also: ISNUMBER().
Sample:
VAR inp TEXT

REPEAT
  inp=INPUT('Enter a floating point value')
  IF not ISFLOAT(inp)
    MSGBOX (inp+" is not a valid floating point number!")
  ENDIF
UNTIL ISFLOAT(inp)
MSGBOX (INP+" = "+TEXT(EXTENDED(INP)))
BYTE ISHEX(value)
Parameters:

value: an expression of type TEXT

more...

less...

Use the ISHEX() function to determine whether the TEXT value is a valid hexadecimal number (that is value solely consists of hexadecimal digits, it may optionally be prefixed by "0x"), max. 64 bits. If value is a valid hexadecimal number, 1 is returned, otherwise 0 is returned.
See also: HEX2NUM(), ISNUMBER().
Sample:
VAR inp TEXT

REPEAT
  inp=INPUT('Enter a hexadecimal value')
  IF not ISHEX(inp)
    MSGBOX (inp+" is not a valid hexadecimal number!")
  ENDIF
UNTIL ISHEX(inp)
BYTE ISNUMBER(value)
Parameters:

value: an expression of type TEXT

more...

less...

Use the ISNUMBER() function to determine whether the TEXT value is a valid ordinal numeric representation either in decimal (e.g. '100'), hexadecimal (e.g. '0xff') or octal (e.g. '755o') notation (max. 64 bits wide). If value is a valid number, 1 is returned, otherwise 0 is returned.
See also: ISFLOAT(), ISHEX().
Sample:
VAR inp TEXT

REPEAT
  inp=INPUT('Enter a number')
  IF not ISNUMBER(inp)
    MSGBOX (inp+" is not a number!")
  ENDIF
UNTIL ISNUMBER(inp)
EXTENDED LOG10(x)*
Parameters:

x: a floating point expression

more...

less...

LOG10() returns the base 10 logarithm of x.
EXTENDED LOGN(x)*
Parameters:

x: a floating point expression

more...

less...

LOGN() returns the natural logarithm of x.
LONGWORD LONGWORD(expr)
Parameters:

expr: an expression

more...

less...

The LONGWORD() function is used to convert the expression expr to the LONGWORD data type.

If expr is a numeric or CHAR expression, the lowest 32 bits of its ordinal value are returned.

If expr is of type TEXT, Tiny Hexer tries to convert the text string to a number. If conversion fails, an error is raised. If conversion succeeds, the lowest 32 bits of the converted number are returned.

In earlier versions of Tiny Hexer, this function was called DWORD(). This alias is deprecated.
See also: Data types.
Sample:
= convert a text to a longword number
VAR inp TEXT dw LONGWORD

REPEAT
  inp = INPUT('Enter a numeric value')
UNTIL ISNUMBER(inp)

LET dw = LONGWORD(inp)

= output hexadecimal
MSGBOX ('The number you entered was (hex): '+HEX(dw))
SIGQWORD MAX(i1, i2)*
EXTENDED MAX(f1, f2)*
Parameters:

i1, i2: ordinal numeric expressions
f1, f2: floating point numeric expressions

more...

less...

The MAX() function returns the greater of the two parameters i1 and i2 or f1 and f2, respectively.
See also: MIN().
Sample:
MSGBOX DEC(MAX(1,2)):= results in "2"
MSGBOX TEXT(MAX(1.5,2.5)):= results in "2.5"
SIGQWORD MIN(i1, i2)*
EXTENDED MIN(f1, f2)*
Parameters:

i1, i2: ordinal numeric expressions
f1, f2: floating point numeric expressions

more...

less...

The MIN() function returns the lesser of the two parameters i1 and i2 or f1 and f2, respectively.
See also: MAX().
Sample:
MSGBOX DEC(MIN(1,2)):= results in "1"
MSGBOX TEXT(MIN(1.5,2.5)):= results in "1.5"
LONGWORD MSGBOX(message [, flags [, title]])
Parameters:

message: expression of type TEXT
flags: optional expression of type LONGWORD
title: optional expression of type TEXT

more...

less...

MSGBOX() opens a dialog displaying the text message.

The optional flags parameter tells Windows to change the behaviour and/or appearance of the dialog (see MSGBOX flags).

MSGBOX() returns the value of the button the user has selected:
  • IDOK (= 1): "OK" button has been selected
  • IDCANCEL (= 2): "Cancel" button has been selected
  • IDABORT (= 3): "Abort" button has been selected
  • IDRETRY (= 4): "Retry" button has been selected
  • IDIGNORE (= 5): "Ignore" button has been selected
  • IDYES (= 6): "Yes" button has been selected
  • IDNO (= 7): "No" button has been selected
  • IDTRYAGAIN (= 10): "Try Again" button has been selected
  • IDCONTINUE (= 11): "Continue" button has been selected

The optional title parameter modifies the title bar caption of the message dialog.
See also: MSGBOX command.
Sample:
INCLUDE 'def.mps'

VAR btn BYTE

btn=MSGBOX('Click a button', MB_CANCELTRYCONTINUE OR MB_ICONASTERISK)

IF btn==IDCANCEL
  MSGBOX "'Cancel' button has been selected"
ELSE
  IF btn==IDCONTINUE
    MSGBOX "'Continue' button has been selected"
  ELSE
    MSGBOX "'Retry' button has been selected"
  ENDIF
ENDIF
TEXT OCT(number [, usetype])
Parameters:

number: an ordinal expression
usetype: an optional expression of type BYTE

more...

less...

Use the OCT() function to convert the ordinal numeric expression number to a octal representation consisting of the characters "0".."7". If the optional parameter usetype is set to 0, numbers < 0 are always converted as 64 bits signed values. If set to 1, the type of number is used to convert negative values. This flag affects the converted representation of negative values only, positive values are always calculated to the shortest possible length.
See also: BIN(), DEC(), HEX().
Sample:
MSGBOX (OCT(BYTE(1))):= shows "1" (8 bits)
MSGBOX (OCT(WORD(256))):= shows "400" (16 bits)
MSGBOX (OCT(LONGWORD(256))):= shows "400" (32 bits, but msbs set to 0)
MSGBOX (OCT(SIGBYTE(-1))):= shows "1777777777777777777777" (64 bits)
MSGBOX (OCT(SIGBYTE(-1),1)):= shows "377" (8 bits)
MSGBOX (OCT(SIGWORD(-1),1)):= shows "177777" (16 bits)
BYTE ODD(x)*
Parameters:

x: an ordinal numerical expression

more...

less...

ODD() returns 1 if the value of x is odd, 0 if it's even or 0.
TEXT PARAMS(index)
Parameters:

index: expression of type LONGWORD

more...

less...

The PARAMS() function returns the contents of the parameter #index (first parameter is at index 0) passed to the script when it's started by a tools menu item.
See also: PARAM_COUNT special variable.
Sample:
= save this script under c:\script1.mps
= start of script 1

= execute script 2 and pass two parameters to it
= parameters are separated by blanks or comma
= multiple parameters enclosed in double quotes are used as single parameters
!CMD.ToolsExecuteScript "c:\\script2.mps", '"First argument", "Second argument"'

END

= end of script 1

= save this script under c:\script2.mps
= start of script 2

VAR lp LONGWORD, param TEXT

= show all parameters
lp=0
WHILE lp < PARAM_COUNT
  param=PARAMS(lp)
  MSGBOX ("Parameter "+DEC(lp+1)+": "+param)
  INC lp, 1
ENDWHILE

END

= end of script 2
SIGQWORD POSITIONS(index)*
Parameters:

index: expression of type SIGQWORD

more...

less...

The POSITIONS() function returns the value of the entry #index in the position list (first entry is at index 0, an index value of -1 returns the value of the entry that has the focus.)
See also: POSITION_COUNT special variable, POSITION_ADD(), POSITION_SELECTED().
Sample:
= show the value of the currently focused entry in the position list
VAR val SIGQWORD

val=POSITIONS(-1)

IF (val == -1)
  ERROR "No entry selected in the position list"
ELSE
  MSGBOX ("Value of the focused entry in the position list: "+TEXT(LONGWORD(val)))
ENDIF
LONGWORD POSITION_ADD(value [, length])*
Parameters:

value, length: expressions of type SIGQWORD

more...

less...

The POSITION_ADD() function is used to add a position value to the position list. The optional parameter length is used to add a selection length. The function returns the index of the new entry in the position list.
See also: POSITION_COUNT special variable, POSITIONS(), POSITION_SELECTED().
Sample:
= add an entry to the position list and select it
VAR index LONGWORD, wasselected BYTE, newpos LONGWORD

= query a value to be added to the position list
newpos=INPUTNUMBER("Enter a position value to be added to the position list")

IF (newpos == 0):END:ENDIF

index=POSITION_ADD(newpos)

= select and focus the newly added item
wasselected = POSITION_SELECTED(index, 1, 1)
BYTE POSITION_SELECTED(index [, doselect [, dosetfocus]])*
Parameters:

index: an expression of type SIGQWORD
doselect, dosetfocus: optional expressions of type BYTE

more...

less...

The POSITION_SELECTED() function is used to tell whether entry #index of the position list is currently selected. The function returns 1 if the entry is selected and 0 otherwise (the first entry is at index 0, an index value of -1 acts on the entry that has the focus.)

The optional doselect parameter can be used to change the entry's selection state (1 selects the item, 0 deselects it).

The optional dosetfocus parameter, when set to 1, makes that entry the focused entry in the position list.
See also: POSITION_COUNT special variable, POSITIONS(), POSITION_ADD().
Sample:
= add an entry to the position list and select it
VAR newpos SIGQWORD, index LONGWORD, wasselected BYTE

= query a value to be added to the position list
newpos=SIGQWORD(INPUT("", "Enter a position value to be added to the position list","-1"))

IF (newpos < 0):END:ENDIF

index=POSITION_ADD(newpos)

= select and focus the newly added position
wasselected = POSITION_SELECTED(index, 1, 1)
LONGWORD RANDOM(max)
Parameters:

max: an expression of type LONGWORD

more...

less...

The RANDOM() function returns an ordinal random number within the range 0..max-1.
See also: FRANDOM and QRANDOM special variables.
Sample:
MSGBOX "Guess a number game", 64

VAR number BYTE, entered BYTE

LABEL start

= randomly choose a number between 1 and 10
LET number = RANDOM(10)+1

LABEL loop

LET entered = BYTE(INPUTNUMBER('Enter a number between 1 and 10'))
IF entered == number
  MSGBOX 'Right!'
ELSE
  IF number < entered
    MSGBOX ('My number is less than '+DEC(entered))
  ELSE
    MSGBOX ('My number is greater than '+DEC(entered))
  ENDIF
  GOTO loop
ENDIF

GOTO start
BYTE REGREAD(key, name, buffer)
Parameters:

key, name: expressions of type TEXT
buffer: VARREF

more...

less...

Use the REGREAD() function to read values from the registry.

key is the name of the registry key. by default, REGREAD() reads values from the HKEY_CURRENT_USER root key. to select another root key, prefix key by the name of the root key (e.g. 'HKEY_LOCAL_MACHINE\Software...').

Note: To read data from Tiny Hexer's settings database rather than from the registry, use the 'HKEY_SETTINGS' pseudo root key.

name is the name of the value in the given registry key.
buffer is a reference to a variable that will contain the value read from the registry.

If the specified value could be read from the registry, 1 is returned, otherwise 0 is returned.
See also: REGWRITE command, INIREAD() function.
Sample:
DEF reg "HKEY_CURRENT_USER\\Temporary Test Key"

= write some data to the registry
regwrite reg, "name1", 2
regwrite reg, "name2", "abc"

VAR val LONGWORD val_t TEXT

= try to read name1 as longword
IF REGREAD(reg, "name1", @val)
  MSGBOX ('Value of name1: '+TEXT(val))
ELSE
  ERROR ('Cannot read name1 value from '+reg)
ENDIF

= try to read name2 as text
IF REGREAD(reg, "name2", @val_t)
  MSGBOX ('Value of name2: '+val_t)
ELSE
  ERROR ('Cannot read name2 value from '+reg)
ENDIF

= delete temporary key
regwrite reg
SIGQWORD ROUND(number)*
Parameters:

number: a numeric expression

more...

less...

ROUND() returns the ordinal value of the argument number, rounded to the nearest ordinal number.
See also: CEIL(), FLOOR(), FRAC(), INT(), TRUNC().
Sample:
MSGBOX (DEC(ROUND(2.499))):= results in "2"
MSGBOX (DEC(ROUND(2.501))):= results in "3"
MSGBOX (DEC(ROUND(-2.499))):= results in "-2"
MSGBOX (DEC(ROUND(-2.501))):= results in "-3"
TEXT SELECTEDITORFILE(title, prompt [, files [, multiselect [, default]]]) *
Parameters:

title, prompt, files (optional): expressions of type TEXT
multiselect: an optional expression of type BYTE
default: an optional expression of type SIGQWORD

more...

less...

The SELECTEDITORFILE() function pops up a dialog that allows you to select currently opened editor files from a list. SELECTEDITORFILE() returns the name (or newline sparated list of names) that has been selected in the dialog.

title is the caption of the dialog, prompt is displayed as a hint label in the dialog.

If the optional files parameter is used and contains file names (separated by newline characters), the dialog only shows these filenames, otherwise all files currently opened are displayed.

If the optional multiselect parameter is set to a value different from zero, the dialog allows to select multiple files (the function returns multiple file names separated by newline characters).

The optional default value is used to specify a preselection when the dialog is displayed: set it to -1 to select all files by default (only if multiselect is enabled), set it to 0 for no preselection or set it to a line index into the files lines "array" (1-based).
Sample:
= show overall size of selected files
VAR selected TEXT

= set decimal output
INCLUDE 'def.mps'

selected = SELECTEDITORFILE('Overall file size', 'Select some files:', '', 1, -1)

VAR amount LONGWORD size SIGQWORD index LONGWORD f FILE
= get the number of returned files
amount = TEXTLINECOUNT(selected)
IF (amount)
  size = 0: = reset size
  index = 0: = reset index
  WHILE (index < amount)
    = open file to get size, filenames are separated by newlines
    = so get the current line via TEXTLINE()
    f = FILEOPEN(('::'+TEXTLINE(selected, index)), 'r')

    INC index, 1

    = retrieve the size of the file and add to the overall size
    INC size, FILESIZE(f)

    FILECLOSE f
  ENDWHILE

  = show the overall size
  MSGBOX ("Number of files:"+DEC(amount)+"\nOverall file size: "+DEC(size)), MB_ICONINFORMATION
ENDIF
LONGWORD SHELL(program [, parameters [, show [, directory [, output]]]])
Parameters:

program, parameters, directory: expressions of type TEXT
show: an expression of type LONGWORD
output: an expression of type VARREF

more...

less...

The SHELL() function is used to execute the external application program. Script execution is always stopped until program has finished. SHELL() returns the exit code of the program, if it cannot be executed, 0xFFFFFFFF is returned.

Optionally the command line arguments parameters can be passed to program.

Additionally you can tell Tiny Hexer Script to show or hide the external application using the show parameter (SW_HIDE, SW_SHOW...)

The optional directory parameter tells Windows to set program's current directory.

The optional output parameter is a reference to a TEXT variable that will contain the output of program after its execution.
See also: SHELL command.
Sample:
VAR exitcode LONGWORD num LONGWORD fname TEXT

num=INPUTNUMBER('Enter an exitcode')

VAR f FILE
= create a temp. batch file
fname=ENVPARSE('%temp%')+'\shelltest1.bat'
f=FILEOPEN(fname,'c')

FILEWRITE f, ('@echo Exiting with code '+DEC(num)+"\r\n")
FILEWRITE f, ('@exit '+DEC(num)+"\r\n")
FILECLOSE f

= run the created batch
exitcode=SHELL(fname)

FILEDELETE (fname)

= show the exitcode
MSGBOX ('Exitcode of '+fname+': '+DEC(exitcode)+" (wanted: "+DEC(num)+")")
SIGBYTE SIGBYTE(expr)
Parameters:

expr: an expression

more...

less...

The SIGBYTE() function is used to convert the expression expr to the SIGBYTE data type. As SIGBYTE is a signed numeric data type, it can only store 7 bits of data though it is a 8 bits wide data type.

If expr is a numeric or CHAR expression, the lowest 7 bits of its ordinal value and its sign are returned.

If expr is of type TEXT, Tiny Hexer tries to convert the text string to a number. If conversion fails, an error is raised. If conversion succeeds, the lowest 7 bits of the converted number and its sign are returned are returned.
See also: Data types.
Sample:
VAR inp TEXT

REPEAT
  REPEAT
    inp = INPUT('', 'Enter a negative integral number',  '-1')
  UNTIL ISNUMBER(inp)
UNTIL (SIGBYTE(inp) < 0)
SIGLONGWORD SIGLONGWORD(expr)
Parameters:

expr: an expression

more...

less...

The SIGLONGWORD() function is used to convert the expression expr to the SIGLONGWORD data type. As SIGLONGWORD is a signed numeric data type, it can only store 31 bits of data though it is a 32 bits wide data type.

If expr is a numeric or CHAR expression, the lowest 31 bits of its ordinal value and its sign are returned.

If expr is of type TEXT, Tiny Hexer tries to convert the text string to a number. If conversion fails, an error is raised. If conversion succeeds, the lowest 31 bits of the converted number and its sign are returned are returned.
See also: Data types.
Sample:
VAR inp TEXT

REPEAT
  REPEAT
    inp = INPUT('', 'Enter a negative integral number',  '-1')
  UNTIL ISNUMBER(inp)
UNTIL (SIGLONGWORD(inp) < 0)
SIGQWORD SIGN(ivalue)*
EXTENDED SIGN(fvalue)*
Parameters:

ivalue: an ordinal numeric expression
fvalue: a floating point numeric expression

more...

less...

The SIGN() function returns the sign of the parameter ivalue or fvalue, respectively.
Sample:
MSGBOX DEC(SIGN(-5)):= results in "-1"
MSGBOX DEC(SIGN(-0)):= results in "0"
MSGBOX DEC(SIGN(5)):= results in "1"
MSGBOX TEXT(SIGN(-5.5)):= results in "-1"
MSGBOX TEXT(SIGN(-0.0)):= results in "0"
MSGBOX TEXT(SIGN(5.5)):= results in "1"
SIGQWORD SIGQWORD(expr)
Parameters:

expr: an expression

more...

less...

The SIGQWORD() function is used to convert the expression expr to the SIGQWORD data type. As SIGQWORD is a signed numeric data type, it can only store 63 bits of data though it is a 64 bits wide data type.

If expr is a numeric or CHAR expression, the lowest 63 bits of its ordinal value and its sign are returned.

If expr is of type TEXT, Tiny Hexer tries to convert the text string to a number. If conversion fails, an error is raised. If conversion succeeds, the lowest 63 bits of the converted number and its sign are returned are returned.

In earlier versions of Tiny Hexer, this function was called QWORD(). This alias is deprecated.
See also: Data types.
Sample:
VAR inp TEXT

REPEAT
  REPEAT
    inp = INPUT('', 'Enter a negative integral number',  '-1')
  UNTIL ISNUMBER(inp)
UNTIL (SIGQWORD(inp) < 0)
SIGWORD SIGWORD(expr)
Parameters:

expr: an expression

more...

less...

The SIGWORD() function is used to convert the expression expr to the SIGWORD data type. As SIGWORD is a signed numeric data type, it can only store 15 bits of data though it is a 16 bits wide data type.

If expr is a numeric or CHAR expression, the lowest 15 bits of its ordinal value and its sign are returned.

If expr is of type TEXT, Tiny Hexer tries to convert the text string to a number. If conversion fails, an error is raised. If conversion succeeds, the lowest 15 bits of the converted number and its sign are returned are returned.
See also: Data types.
Sample:
VAR inp TEXT

REPEAT
  REPEAT
    inp = INPUT('', 'Enter a negative integral number',  '-1')
  UNTIL ISNUMBER(inp)
UNTIL (SIGWORD(inp) < 0)
EXTENDED SIN(number)*
Parameters:

number: a floating point expression

more...

less...

SIN() returns the sine of the argument number (radian).
SINGLE SINGLE(expr)
Parameters:

expr: an expression

more...

less...

The SINGLE() function is used to convert the expression expr to the SINGLE precision floating point data type.

If expr is a numeric or CHAR expression, its numeric value is returned.

If expr is of type TEXT, Tiny Hexer tries to convert the text string to a floating point number. If conversion fails, an error is raised.
See also: Data types.
Sample:
VAR inp TEXT si SINGLE do DOUBLE ex EXTENDED

REPEAT
  inp = INPUT('Enter a floating point value')
UNTIL ISFLOAT(inp)

LET si = SINGLE(inp)
LET do = DOUBLE(inp)
LET ex = EXTENDED(inp)

MSGBOX ('The number you entered was (single precision): '+TEXT(si))
MSGBOX ('The number you entered was (double precision): '+TEXT(do))
MSGBOX ('The number you entered was (extended precision): '+TEXT(ex))
EXTENDED SQRT(x)*
Parameters:

x: a floating point expression

more...

less...

SQRT() returns the square root of x.
SIGQWORD TAG_LEN(ref)
Parameters:

ref: an expression of type VARREF

more...

less...

The TAG_LEN() function returns the length tag of the variable referenced by ref.

If the referenced variable is not tagged, -1 is returned.
See also: Variable tagging, COPYTAGS command, TAGVAR command, TAG_POS(), OPTION READTAGS directive.
Sample:
= enable variable tagging
OPTION READTAGS, 1

VAR f FILE, t TEXT, msg TEXT

= open tiny hexer itself
f=FILEOPEN(ENVPARSE('%apppath%\mpth.exe'),'r')

= locate a specific position
FILESEEK f, 986284

= read text from file with automatic tagging
FILEREAD f, t, 9
= t is now tagged with file position and data length

FILECLOSE f

msg='Data read from file: "'+t+'"'+"\n\r"
CONCAT msg, 'At position: '+DEC(TAG_POS(@t))+"\n\r"
CONCAT msg, 'Data length: '+DEC(TAG_LEN(@t))+"\n\r"

MSGBOX msg
SIGQWORD TAG_POS(ref)
Parameters:

ref: an expression of type VARREF

more...

less...

The TAG_POS() function returns the position tag of the variable referenced by ref.

If the referenced variable is not tagged, -1 is returned.
See also: Variable tagging, COPYTAGS command, TAGVAR command, TAG_LEN(), OPTION READTAGS directive.
Sample:
= enable variable tagging
OPTION READTAGS, 1

VAR f FILE, t TEXT, msg TEXT

= open tiny hexer itself
f=FILEOPEN(ENVPARSE('%apppath%\mpth.exe'),'r')

= locate a specific position
FILESEEK f, 986284

= read text from file with automatic tagging
FILEREAD f, t, 9
= t is now tagged with file position and data length

FILECLOSE f

msg='Data read from file: "'+t+'"'+"\n\r"
CONCAT msg, 'At position: '+DEC(TAG_POS(@t))+"\n\r"
CONCAT msg, 'Data length: '+DEC(TAG_LEN(@t))+"\n\r"

MSGBOX msg
EXTENDED TAN(number)*
Parameters:

number: a floating point expression

more...

less...

TAN() returns the tangent of the argument number (radian).
TEXT TEXT(expr)
Parameters:

expr: an expression

more...

less...

The TEXT() function is used to convert the expression expr to the TEXT data type.

If expr is a numeric expression, its value is converted to a textual represention; the conversion format depends on the values of the NUMBER_RADIX, NUMBER_PREFIX and NUMBER_SUFFIX special variables if the number is ordinal, when converting floating point numbers, they are always converted using base (radix) 10.

If expr is of type TEXT or CHAR, a copy of the string is returned.
See also: BIN(), DEC(), HEX(), OCT(); Data types; NUMBER_RADIX, NUMBER_PREFIX and NUMBER_SUFFIX special variables.
Sample:
= show different number to text conversions
VAR number WORD txt TEXT

number=64738

= binary (radix 2)
NUMBER_RADIX=2
NUMBER_PREFIX='%'
NUMBER_SUFFIX=''

MSGBOX TEXT(number)

= octal (radix 8)
NUMBER_RADIX=8
NUMBER_PREFIX=''
NUMBER_SUFFIX='o'

MSGBOX TEXT(number)

= octal (radix 8), alternate output format
NUMBER_RADIX=8
NUMBER_PREFIX='0'
NUMBER_SUFFIX=''

MSGBOX TEXT(number)

= decimal (base 10)
NUMBER_RADIX=10
NUMBER_PREFIX=''
NUMBER_SUFFIX=''

MSGBOX TEXT(number)

= decimal (base 10), "alternate" format
NUMBER_RADIX=10
NUMBER_PREFIX='(prefix) '
NUMBER_SUFFIX=' (suffix)'

MSGBOX TEXT(number)

= hexadezimal (radix 16)
NUMBER_RADIX=16
NUMBER_PREFIX='0x'
NUMBER_SUFFIX=''

MSGBOX TEXT(number)

= hexadezimal (radix 16), alternate output format
NUMBER_RADIX=16
NUMBER_PREFIX=''
NUMBER_SUFFIX='h'

MSGBOX TEXT(number)
NUMBER TEXT2DATA(data, index, count)
Parameters:

data: an expression of type TEXT
index, count: expressions of type SIGBYTE

more...

less...

The TEXT2DATA() function is the counterpart of the DATA2TEXT() function. It is used to extract numeric values from tables created by DATA2TEXT().

data contains the binary data values.

index is the index to the data TEXT string, where data extraction starts, multiplied by the count parameter value.

count is either the negative value of a data type constant or the amount of data to be extracted (deprecated). The type of the data returned by TEXT2DATA() depends on this parameter.
See also: DATA2TEXT(), TEXT2DATABE().
Sample:
= power of 2 table example
INCLUDE 'def.mps'
OPTION GLOBALVARS, 1

VAR ptable TEXT, num SIGQWORD

= store the next power of 2 as SIGQWORD in ptable
LOCAL create_table
  CONCAT ptable, DATA2TEXT(SIGQWORD(num))
  INC num, num
ENDLOCAL

VAR inp TEXT q SIGQWORD power SIGQWORD

LET num = 1
LET ptable = ''
LOOP create_table 63

REPEAT
  REPEAT
    REPEAT
      LET inp = INPUT('Enter a number between 0 and 62')
    UNTIL ISNUMBER(inp)
    LET q = SIGQWORD(inp)
  UNTIL (q < 63) AND (q >= 0)

  = power values are stored as SIGQWORD, so SIGQWORD_SIZE or -SIGQWORD_DATA must be used
  = to access the correct data
  power = TEXT2DATA(ptable, q, -SIGQWORD_DATA)
  MSGBOX ( '2 ** '+DEC(q)+' = '+DEC(power))

UNTIL 0
NUMBER TEXT2DATABE(data, index, count)
Parameters:

data: an expression of type TEXT
index, count: expressions of type LONGWORD

more...

less...

The TEXT2DATABE() function is the counterpart of the DATA2TEXTBE() function. It is used to extract numeric values from tables created by DATA2TEXTBE().

data contains the binary data values in BIG ENDIAN format.

index is the index to the data TEXT string, where data extraction starts, multiplied by the count parameter value.

count is either the negative value of a data type constant or the amount of data to be extracted (deprecated). The type of the data returned by TEXT2DATABE() depends on this parameter.
See also: DATA2TEXTBE(), TEXT2DATA().
Sample:
= power of 2 table example
INCLUDE 'def.mps'
OPTION GLOBALVARS, 1

VAR ptable TEXT, num SIGQWORD

= store the next power of 2 as SIGQWORD in ptable
LOCAL create_table
  CONCAT ptable, DATA2TEXTBE(SIGQWORD(num))
  INC num, num
ENDLOCAL

VAR inp TEXT q SIGQWORD power SIGQWORD

LET num = 1
LET ptable = ''
LOOP create_table 63

REPEAT
  REPEAT
    REPEAT
      LET inp = INPUT('Enter a number between 0 and 62')
    UNTIL ISNUMBER(inp)
    LET q = SIGQWORD(inp)
  UNTIL (q < 63) AND (q >= 0)

  = power values are stored as SIGQWORD, so SIGQWORD_SIZE or -SIGQWORD_DATA must be used
  = to access the correct data
  power = TEXT2DATABE(ptable, q, -SIGQWORD_DATA)
  MSGBOX ( '2 ** '+DEC(q)+' = '+DEC(power))

UNTIL 0
TEXT TEXTCHOP(string [, flags])
Parameters:

string, flags: expressions of type TEXT

more...

less...

TEXTCHOP() is used to remove preceding and/or trailing whitespaces from a string (whitespaces are characters from 0x00..0x20).

string is the text expression to be chopped.

The optional flags parameter tells the function where to remove whitespaces:
  • "pt" (default): remove preceding and trailing whitespaces
  • "p": remove preceding whitespaces only
  • "t": remove trailing whitespaces only
Sample:
VAR in TEXT, out TEXT

= generate a string with garbage at beginning and end
in = "\t STRING\n\r"
= in: (0x09)(0x20)"STRING"(0x0a)(0x0d)

out = TEXTCHOP(in) := (or out = TEXTCHOP(in,"pt"))
= out now contains "STRING"

out = TEXTCHOP(in, "p")
= out now contains "STRING"(0x0a)(0x0d)

out = TEXTCHOP(in, "t")
= out now contains (0x09)(0x20)"STRING"
TEXT TEXTCONVERT(string, source, target)
Parameters:

string: an expression of type TEXT
source, target: expressions of type BYTE

more...

less...

TEXTCONVERT() is used to convert the text string from character translation source to character translation target.

source and target can be one of the following values (symbols are defined in DEF.MPS):
  • TEXTCONVERT_ANSI (= 1): the text string is in ANSI format (source) or is to be converted into ANSI format (target)
  • TEXTCONVERT_DOS8 (= 2): DOS character set
  • TEXTCONVERT_ASCII7 (= 3): 7 Bit ASCII character set
  • TEXTCONVERT_MAC (= 4): Macintosh™ character set
  • TEXTCONVERT_EBCDIC (= 5): EBCDIC codepage 38 character set
  • TEXTCONVERT_UNICODE (= 6): Two Byte Unicode character set (little endian)
  • TEXTCONVERT_UNICODEBE (= 7): Two Byte Unicode character set (big endian)
  • TEXTCONVERT_CUSTOM (= 255): Custom character set
Sample:
= include the TEXTCONVERT_... symbols
INCLUDE 'DEF.MPS'

VAR sAnsi TEXT, sEbcdic TEXT, sUnicode Text

= store a text
sAnsi = 'Hello world!'

= now convert the text from ansi to ebcdic
sEbcdic = TEXTCONVERT(sAnsi, TEXTCONVERT_ANSI, TEXTCONVERT_EBCDIC)
= now the text is stored in ebcdic cp 38 in sEbcdic

= now convert the text from ebcdic to unicode
sUnicode = TEXTCONVERT(sEbcdic, TEXTCONVERT_EBCDIC, TEXTCONVERT_UNICODE)
= now the text is stored in unicode little endian in sUnicode

= now convert the text back from unicode to ansi
sAnsi = TEXTCONVERT(sUnicode, TEXTCONVERT_UNICODE, TEXTCONVERT_ANSI)
= now the text 'Hello world!' should be stored in ansi in sAnsi

= show whether it works (many special and unicode characters cannot be converted correctly, but
= normal ascii characters should work)
MSGBOX sAnsi
TEXT TEXTCOPY(string, start [, count])
Parameters:

string: an expression of type TEXT
start, count: expressions of type LONGWORD

more...

less...

The TEXTCOPY() function returns a part of the value of string.

start is the index to the first character of string to copy (the first char is at index 1, not 0!).

count is the amount of characters to copy. If this parameter is omitted, all characters from start up to the last character are copied.
See also: TEXTLEN(), TEXTPOS(), TEXTCUT().
Sample:
var txt1 TEXT, txt2 TEXT
txt1="This is a text"

txt2=TEXTCOPY(txt1, 6, 2)
= txt2 now contains the text "is"

MSGBOX txt2
TEXT TEXTCUT(stringref, start [, count])
Parameters:

stringref: an expression of type VARREF
start, count: expressions of type LONGWORD

more...

less...

The TEXTCUT() function extracts a part of the value of the TEXT variable referenced by stringref and returns the extracted text.

start is the index to the first character of the TEXT variable referenced by stringref to extract (the first char is at index 1, not 0!).

count is the amount of characters to extract. If this parameter is omitted, all characters from start up to the last character are extracted.
See also: TEXTCOPY().
Sample:
var txt1 TEXT, txt2 TEXT
txt1="This is a text"

txt2=TEXTCUT(@txt1, 6, 2)
= txt2 now contains the text "is", txt1 now contains "This  a text"

MSGBOX txt2
MSGBOX txt1
LONGWORD TEXTLEN(string)
Parameters:

string: an expression of type TEXT

more...

less...

TEXTLEN() returns the length (in characters) of string.
See also: TEXTCOPY(), TEXTPOS().
Sample:
var inp TEXT

REPEAT
  inp=INPUT('Enter a text consisting of exactly six characters')
UNTIL TEXTLEN(inp) == 6
TEXT TEXTLINE(lines, index)*
Parameters:

lines: an expression of type TEXT
index: an expression of type LONGWORD

more...

less...

TEXTLINE() returns the line index of the text lines. This function is used to work with text files (TEXT variables that contain multiple lines separated by newline characters (chr(10) and/or chr(13)). The first line is at index 0.
See also: TEXTLINECOUNT().
Sample:
var str TEXT line TEXT

str="Line 1\nLine 2\rLine 3":= supports different newline characters

= display the third number (as the function is zero-based, use index 2!)
line=TEXTLINE(str, 2)

MSGBOX ("Third line is '"+line+"'")
LONGWORD TEXTLINECOUNT(lines)*
Parameters:

lines: an expression of type TEXT

more...

less...

TEXTLINECOUNT() returns the number of lines stored in the text lines. Lines are separated by newline characters (chr(10) and/or chr(13)).
See also: TEXTLINE().
Sample:
var str TEXT count LONGWORD

str="Line 1"+CHAR(0x0d)+CHAR(0x0a)+"Line 2"+CHAR(0x0d)+"Line 3"+CHAR(0x0a)+"Line 4":= supports 0d0a, 0d and 0a

= count the number of lines in str
count=TEXTLINECOUNT(str)

MSGBOX (DEC(count)+' lines in text')
TEXT TEXTLOWER(string)
Parameters:

string: an expression of type TEXT

more...

less...

TEXTLOWER() converts all characters in string to lower case and returns the converted TEXT.
See also: TEXTUPPER().
Sample:
var str TEXT

str="Lower Case"

str=TEXTLOWER(str)
= str is set to "lower case" now

MSGBOX str
LONGWORD TEXTPOS(substr, string)
Parameters:

substr, string: expressions of type TEXT

more...

less...

TEXTPOS() returns the index of the first occurance of the string substr in string. If substr is not contained in string, 0 is returned.
See also: TEXTCOPY(), TEXTLEN().
Sample:
var inp TEXT

REPEAT
  inp=INPUT('Enter a string that contains the text "hex"')
UNTIL TEXTPOS("hex",inp) > 0
TEXT TEXTUPPER(string)
Parameters:

string: an expression of type TEXT

more...

less...

TEXTUPPER() converts all characters in string to upper case and returns the converted TEXT.
See also: TEXTLOWER().
Sample:
var str TEXT

str="Upper Case"

str=TEXTUPPER(str)
= str is set to "UPPER CASE" now

MSGBOX str
SIGQWORD TRUNC(number)*
Parameters:

number: a numeric expression

more...

less...

TRUNC() returns the ordinal value of the argument number, rounded towards 0.
See also: CEIL(), FLOOR(), FRAC(), INT(), ROUND().
Sample:
MSGBOX (DEC(TRUNC(2.0))):= results in "2"
MSGBOX (DEC(TRUNC(2.9999))):= results in "2"
MSGBOX (DEC(TRUNC(-2.9999))):= results in "-2"
BYTE TYPEOF(expr)
Parameters:

expr: an expression

more...

less...

TYPEOF() returns the data type of expr.

An expression has one of the following data types:
  • CHAR_DATA (=1): CHAR data type
  • BYTE_DATA (=2): BYTE data type
  • WORD_DATA (=3): WORD data type
  • LONGWORD_DATA (=4): LONGWORD data type
  • SIGQWORD_DATA (=5): SIGQWORD data type
  • TEXT_DATA (=6): TEXT data type
  • FILE_DATA (=7): FILE data type
  • VARREF_DATA (=8): VARREF data type
  • SINGLE_DATA (=9): SINGLE data type
  • DOUBLE_DATA (=10): DOUBLE data type
  • EXTENDED_DATA (=11): EXTENDED data type
  • COMP_DATA (=12): COMP data type
  • SIGBYTE_DATA (=13): SIGBYTE data type
  • SIGWORD_DATA (=14): SIGWORD data type
  • SIGLONGWORD_DATA (=14): SIGLONGWORD data type
See also: Data types.
Sample:
= show data type example
INCLUDE 'def.mps'
OPTION GLOBALVARS, 1

VAR output TEXT

= get a textual data type representation
LOCAL getdatatype
  VAR stack VARREF
  VAR type SIGBYTE
  VAR types TEXT
  LET types = <<
none
character
unsigned byte
unsigned word
unsigned long
signed quad
text
file
variable reference
single float
double float
extended float
comp float
signed byte
signed word
signed long
>>

  POP stack
  LET type = TYPEOF(DEREF(stack))
  IF ((type <= SIGLONGWORD_DATA) AND (type >= 0))
    RETURN TEXTLINE(types, type)
  ENDIF
  RETURN "unknown"

ENDLOCAL

LOCAL sub_tp
  VAR msg TEXT varn TEXT
  LET msg = #getdatatype
  POP varn
  CONCAT output, (varn+" is of type "+msg+"\n")
ENDLOCAL

VAR charV CHAR, byteV BYTE, wordV WORD, longwordV LONGWORD
VAR sigqwordV SIGQWORD, textV TEXT, fileV FILE, refV VARREF, noneV NONE
VAR singleV SINGLE, doubleV DOUBLE, extendedV EXTENDED, compV COMP
VAR sigbyteV SIGBYTE, sigwordV SIGWORD, siglongwordV SIGLONGWORD

call sub_tp, 'charV', @charV
call sub_tp, 'byteV', @byteV
call sub_tp, 'wordV', @wordV
call sub_tp, 'longwordV', @longwordV

call sub_tp, 'sigqwordV', @sigqwordV
call sub_tp, 'textV', @textV
call sub_tp, 'fileV', @fileV
call sub_tp, 'refV', @refV
call sub_tp, 'noneV', @noneV

call sub_tp, 'singleV', @singleV
call sub_tp, 'doubleV', @doubleV
call sub_tp, 'compV', @compV
call sub_tp, 'extendedV', @extendedV

call sub_tp, 'sigbyteV', @sigbyteV
call sub_tp, 'sigwordV', @sigwordV
call sub_tp, 'siglongwordV', @siglongwordV

TEXTBOX output
WORD WORD(expr)
Parameters:

expr: an expression

more...

less...

The WORD() function is used to convert the expression expr to the WORD data type.

If expr is a numeric or CHAR expression, the lowest 16 bits of its ordinal value are returned.

If expr is of type TEXT, Tiny Hexer tries to convert the text string to a number. If conversion fails, an error is raised. If conversion succeeds, the lowest 16 bits of the converted number are returned.
See also: Data types.
Sample:
= convert a text to a word number
VAR inp TEXT w WORD

REPEAT
  inp = INPUT('Enter a numeric value')
UNTIL ISNUMBER(inp)

LET w = WORD(inp)

= output hexadecimal
MSGBOX ('The number you entered was (hex): '+HEX(w))


Tiny Hexer Script: Graphical user interfaces*

As of version 1.6.0.2 of Tiny Hexer, you can use custom dialogs in scripts to interact with the user. This functionality is stored in the plugin plugin_scriptgui.ths. The gui related constants are defined in the include file gui.mps.

Note: At the time being, documentation for the GUI functionality of Tiny Hexer Script is "rough-and-ready". It will be improved in a later release of this help file (if and when time permits...)
  • GUI functions
  • GUI control types
  • GUI control properties
  • Event handlers

GUI functions

GUIADDITEM(), GUICREATE(), GUIDELETEITEM(), GUIDESTROY(), GUIEXISTS(), GUIGETITEM(), GUIGETITEMCOUNT(), GUIGETPROP(), GUIITEMSELECTED(), GUIPROCESSMESSAGES(), GUISELECTITEM(), GUISETITEM(), GUISETPROP(), GUISHOWMODAL()

Use the GUIADDITEM() function to add an item to the ITEMS list of a 'COMBOBOX', 'LISTBOX', 'MEMO' or 'RADIOGROUP' control.

Parameters:

  • PATHANDNAME (TEXT): Name of the control which must have an ITEMS list to be queried (alphanumeric characters and underscore). When querying a control owned by a FORM, precede the control name with the name of the FORM and a dot character (e.g. 'FORM1.MEMO1').
  • VALUE (TEXT): The data to be added to the items list.
  • INDEX (NUMBER, optional): If this value is omitted, the new data is added to the end of the items list. If this value is given, the new data is inserted at the specified position (e.g. to insert an item as the first entry, use the index value 0)

Return value:

This function returns a (pointless) numeric value different from 0. If an error occurs while the function is executed, the script is terminated unless the ERRORHANDLER command is used.

Use the GUICREATE() function to create a dialog or a control on a dialog.

Parameters:

  • TYPE (TEXT): Type of the control to create. Currently the following control types are supported: 'BUTTON', 'CHECKBOX', 'COMBOBOX', 'EDIT', 'FORM', 'GROUPBOX', 'LISTBOX', 'MEMO', 'RADIOBUTTON', 'RADIOGROUP', 'STATIC'.
  • PATHANDNAME (TEXT): Name of the control to create (alphanumeric characters and underscore). When creating a control on an already created FORM, precede the control name with the name of the FORM and a dot character (e.g. 'FORM1.BUTTON1'). When creating a control to be owned by an already created form, but to be put on another control (like a GROUPBOX), precede the control name with the name of the form, a dot character, the name of the "parent" control and another dot character (e.g. 'FORM1.GROUPBOX1.BUTTON1').
  • PROPNAME (TEXT, optional): Name of a control property to be set at creation time of the control
  • PROPVALUE (TEXT/NUMBER, optional): Value of the control property PROPNAME to be set at creation time of the control

Return value:

This function returns a (pointless) numeric value different from 0. If an error occurs while the function is executed, the script is terminated unless the ERRORHANDLER command is used.

Notes:

  • Multiple (or no) PROPNAME/PROPVALUE pairs may occur in a GUICREATE() call.
  • If a FORM is created, it is not automatically made visible. Use the VISIBLE control property or the GUISHOWMODAL() function to show a form after creating all subordinate controls.

Use the GUIDELETEITEM() function to remove an item from the ITEMS list of a 'COMBOBOX', 'LISTBOX', 'MEMO' or 'RADIOGROUP' control.

Parameters:

  • PATHANDNAME (TEXT): Name of the control which must have an ITEMS list to be queried (alphanumeric characters and underscore). When querying a control owned by a FORM, precede the control name with the name of the FORM and a dot character (e.g. 'FORM1.MEMO1').
  • INDEX (NUMBER): Index of the item to be removed (first item is at index 0)

Return value:

This function returns a (pointless) numeric value different from 0. If an error occurs while the function is executed, the script is terminated unless the ERRORHANDLER command is used.

Use the GUIDESTROY() function to remove a previously created dialog or control chain permanently from memory.

Parameters:

  • PATHANDNAME (TEXT): Name of the control to remove (alphanumeric characters and underscore). When removing a control previously created on an already existing FORM, precede the control name with the name of the FORM and a dot character (e.g. 'FORM1.BUTTON1'). If a FORM is to be destroyed, all subordinate controls are automatically destroyed, too.

Return value:

This function returns a (pointless) numeric value different from 0. If an error occurs while the function is executed, the script is terminated unless the ERRORHANDLER command is used.

Notes:

  • Never call this function in an event handler.

Use the GUIEXISTS() function to determine whether a control or dialog has already been created.

Parameters:

  • PATHANDNAME (TEXT): Name of the control to be queried (alphanumeric characters and underscore). When querying a control owned by a FORM, precede the control name with the name of the FORM and a dot character (e.g. 'FORM1.BUTTON1').

Return value:

This function returns 0 if the control does not exist and a value other than 0 if the control exists.

Use the GUIGETITEM() function to retrieve a value of the ITEMS list of a 'COMBOBOX', 'LISTBOX', 'MEMO' or 'RADIOGROUP' control.

Parameters:

  • PATHANDNAME (TEXT): Name of the control which must have an ITEMS list to be queried (alphanumeric characters and underscore). When querying a control owned by a FORM, precede the control name with the name of the FORM and a dot character (e.g. 'FORM1.MEMO1').
  • INDEX (NUMBER): Index of the item to retrieve (first item is at index 0)

Return value:

This function returns the textual value of the entry in the control's ITEMS list at the specified index.

Use the GUIGETITEMCOUNT() function to retrieve the number of entries of the ITEMS list of a 'COMBOBOX', 'LISTBOX', 'MEMO' or 'RADIOGROUP' control.

Parameters:

  • PATHANDNAME (TEXT): Name of the control which must have an ITEMS list to be queried (alphanumeric characters and underscore). When querying a control owned by a FORM, precede the control name with the name of the FORM and a dot character (e.g. 'FORM1.MEMO1').

Return value:

This function returns the number of entries in the control's ITEMS list.

Use the GUIGETPROP() function to retrieve the value of a control property.

Parameters:

  • PATHANDNAME (TEXT): Name of the control to be queried (alphanumeric characters and underscore). When querying a control owned by a FORM, precede the control name with the name of the FORM and a dot character (e.g. 'FORM1.BUTTON1').
  • PROPNAME (TEXT): Name of the control property to query.

Return value:

This function returns the value (either a numeric or textual value) of the queried control property.

Use the GUIITEMSELECTED() function to check whether an item in a 'LISTBOX' control is currently selected.

Parameters:

  • PATHANDNAME (TEXT): Name of the LISTBOX control to be queried (alphanumeric characters and underscore). Precede the control name with the name of the parent FORM and a dot character (e.g. 'FORM1.LISTBOX1').
  • INDEX (NUMBER): Index of the item whose state is to retrieve (first item is at index 0)

Return value:

If the item at INDEX is currently selected, the function returns a value different from 0, otherwise 0 is returned. If an error occurs while the function is executed, the script is terminated unless the ERRORHANDLER command is used.

Notes:

  • Multiple LISTBOX items can be selected only if its MULTISELECT property is set to TRUE. When not in multiselect mode, use the ITEMINDEX property to get the index of the currently selected item.

Call the GUIPROCESSMESSAGES() function periodically to let the gui engine process user input in non-modal dialogs.

Parameters:

This function has no parameters.

Return value:

This function returns a (pointless) numeric value different from 0.

Notes:

  • If a FORM is displayed using the GUISHOWMODAL() function, the script is suspended and will resume after the FORM has been closed. In this case user input processing is done automatically. But if a FORM is displayed by setting its VISIBLE control property, the script immediately continues at the next command and thus prevents the gui engine from being executed. In this case you have to execute the gui processing engine manually by calling this function periodically.

Use the GUISELECTITEM() function to change the selected state of an item in a 'LISTBOX' control.

Parameters:

  • PATHANDNAME (TEXT): Name of the LISTBOX control to be queried (alphanumeric characters and underscore). Precede the control name with the name of the parent FORM and a dot character (e.g. 'FORM1.LISTBOX1').
  • INDEX (NUMBER): Index of the item whose state is to be changed (first item is at index 0)
  • VALUE (NUMBER): Use 0 to de-select an item, any other value to select an item

Return value:

This function returns a (pointless) numeric value different from 0. If an error occurs while the function is executed, the script is terminated unless the ERRORHANDLER command is used.

Notes:

  • Multiple LISTBOX items can be selected only if its MULTISELECT property is set to TRUE. When not in multiselect mode, use the ITEMINDEX property to change the selected item.

Use the GUISETITEM() function to change the value of an entry in the ITEMS list of a 'COMBOBOX', 'LISTBOX', 'MEMO' or 'RADIOGROUP' control.

Parameters:

  • PATHANDNAME (TEXT): Name of the control which must have an ITEMS list to be queried (alphanumeric characters and underscore). When querying a control owned by a FORM, precede the control name with the name of the FORM and a dot character (e.g. 'FORM1.MEMO1').
  • INDEX (NUMBER): Index of the item to change (first item is at index 0)
  • VALUE (TEXT): The new value of the ITEMS' entry at the specified index.

Return value:

This function returns a (pointless) numeric value different from 0. If an error occurs while the function is executed, the script is terminated unless the ERRORHANDLER command is used.

Use the GUISETPROP() function to change the value of a control property.

Parameters:

  • PATHANDNAME (TEXT): Name of the control to be queried (alphanumeric characters and underscore). When querying a control owned by a FORM, precede the control name with the name of the FORM and a dot character (e.g. 'FORM1.BUTTON1').
  • PROPNAME (TEXT): Name of the control property to change.
  • PROPVAL (TEXT/NUMBER): New value of the control property PROPNAME.

Return value:

This function returns a (pointless) numeric value different from 0. If an error occurs while the function is executed, the script is terminated unless the ERRORHANDLER command is used.

Use the GUISHOWMODAL() function to display a FORM modally.

Parameters:

  • PATHANDNAME (TEXT): Name of the FORM to be displayed (alphanumeric characters and underscore).

Return value:

This function returns the numeric value of the FORM'S MODALRESULT control property.

Notes:

  • If a FORM is displayed using this function, the script is suspended and will resume after the FORM has been closed. The FORM can be closed by pressing ALT+F4 or clicking a (previously created) BUTTON whose MODALRESULT control property is set to a value different from 0. The function returns the value of this MODALRESULT control property.

GUI control types

BUTTON, CHECKBOX, COMBOBOX, EDIT, FORM, GROUPBOX, LISTBOX, MEMO, RADIOBUTTON, RADIOGROUP, STATIC

BUTTON: a push-button which displays a text and can be clicked by the user.

Special properties: CANCEL, CAPTION, DEFAULT, MODALRESULT
CHECKBOX: a control which displays a text and lets the user toggle its state

Special properties: ALLOWGRAYED, CAPTION, CHECKED, STATE
COMBOBOX: a combination of an EDIT control and a LISTBOX control.

Special properties: STYLE (see also special properties of EDIT, LISTBOX)
Special event handlers: ONSELECT (see also special event handlers of EDIT)
EDIT: lets the user enter text via the keyboard

Special properties: AUTOSELECT, AUTOSIZE, HIDESELECTION, MAXLENGTH, PASSWORDCHAR, READONLY, SELLENGTH, SELSTART, SELTEXT, TEXT
Special event handlers: ONCHANGE
FORM: a root control (i.e. a dialog) that contains other controls.

Special properties: BORDERICONS, BORDERSTYLE, CAPTION, CLIENTHEIGHT, CLIENTWIDTH, MODALRESULT, POSITION, WINDOWSTATE
Special event handlers: ONCLOSE, ONCREATE, ONDESTROY, ONHIDE, ONSHOW
GROUPBOX: a control that can contain other controls to group them.

Special properties: CAPTION
LISTBOX: a control which contains a list of entries that can be clicked (and thus selected) by the user.

Special properties: ITEMINDEX, ITEMS, MULTISELECT, SELCOUNT
MEMO: lets the user enter text via the keyboard (similar to the EDIT control, but MEMO can handle multiple lines via its ITEMS property)

Special properties: HIDESELECTION, ITEMS, MAXLENGTH, READONLY, SCROLLBARS, SELLENGTH, SELSTART, SELTEXT, TEXT
Special event handlers: ONCHANGE
RADIOBUTTON: a control which displays a text and lets the user toggle its state. The RADIOBUTTON control is similar to the CHECKBOX control, but just one radio button in a group can be checked at once. All radio buttons which share the same parent control (a FORM or GROUPBOX control) belong to the same group.

Special properties: CAPTION, CHECKED
RADIOGROUP: a combination of a GROUPBOX control and a group of two ore more RADIOBUTTON controls. The RADIOBUTTONs on this control are managed via the ITEMS and ITEMINDEX properties.

Special properties: CAPTION, COLUMNS, ITEMINDEX, ITEMS
STATIC: a control showing a static text.

Special properties: AUTOSIZE, CAPTION, LAYOUT, TRANSPARENT

GUI control properties

Each GUI control has various properties which affect the control's behaviour and appearance. Some of them are common to all control types (like LEFT, RIGHT, WIDHT, HEIGHT and VISIBLE), other properties only apply to certain control types (like MODALRESULT, which only applies to the control types FORM and BUTTON). Use the GUISETPROP() or GUIGETPROP() functions to change or retrieve a control property, respectively.

Properties common to most or all control types: ALIGN, COLOR, ENABLED, FOCUSED, FONTCOLOR, FONTHEIGHT, FONTNAME, FONTSTYLE, HEIGHT, KEY, LEFT, PARENTCOLOR, PARENTFONT, SHIFT, TAG, TOP, VISIBLE, WIDTH, WORDWRAP
Special properties: ALLOWGRAYED, AUTOSELECT, AUTOSIZE, BORDERICONS, BORDERSTYLE, CANCEL, CAPTION, CHECKED, CLIENTHEIGHT, CLIENTWIDTH, COLUMNS, DEFAULT, HIDESELECTION, ITEMINDEX, ITEMS, LAYOUT, MAXLENGTH, MODALRESULT, MULTISELECT, PASSWORDCHAR, POSITION, READONLY, SCROLLBARS, SELCOUNT, SELLENGTH, SELSTART, SELTEXT, STATE, STYLE, TEXT, TRANSPARENT, WINDOWSTATE

ALIGN (BYTE): Tells the gui engine how the control is aligned regarding the dimensions of the parent control. Possible values:

  • GUI_ALIGN_NONE (0): no gui element aligning
  • GUI_ALIGN_TOP (1): aligns the control at the top of the parent element
  • GUI_ALIGN_BOTTOM (2): " at the bottom of the parent element
  • GUI_ALIGN_LEFT (3): " at the left of the parent element
  • GUI_ALIGN_RIGHT (4): " at the right of the parent element
  • GUI_ALIGN_ALL (5): " all over the parent element

Applies to: GROUPBOX, LISTBOX, MEMO, RADIOGROUP, STATIC

COLOR (LONGWORD): Color of the control. A color value consists of three byte values: RED, GREEN, BLUE. To set a new color, use the formula (BLUE << 16) OR (GREEN << 8) OR RED

Applies to: All control types but BUTTON

ENABLED (BYTE): 0: The control is not enabled (the user cannot interact with the control), 1: the control is enabled

Applies to: All control types

FOCUSED (BYTE): 0: The control is not currently focused (i.e. it isn't the control that the user has activated), 1: the control is focused

Applies to: All control types but STATIC

FONTCOLOR (LONGWORD): Color of the control's font. A color value consists of three byte values: RED, GREEN, BLUE. To set a new font color, use the formula (BLUE << 16) OR (GREEN << 8) OR RED

Applies to: All control types

FONTHEIGHT (SIGQWORD): Height of the control's font in pixels

Applies to: All control types

FONTNAME (TEXT): Name of the control's font (e.g. "Arial", "Courier New")

Applies to: All control types

FONTSTYLE (WORD): Style of the control's font. The property can be set to a combination (use the OR operator) of the following values:

  • GUI_FONTSTYLE_BOLD (1): bold font
  • GUI_FONTSTYLE_ITALIC (2): italic font
  • GUI_FONTSTYLE_UNDERLINE (4): underline
  • GUI_FONTSTYLE_STRIKE (8): strike through

Applies to: All control types

HEIGHT (LONGWORD): Overall height of the control

Applies to: All control types

KEY (WORD): Current virtual key code, only valid in the ONKEY event handler.

Applies to: All control types but STATIC

LEFT (SIGQWORD): Left position of the control relative to its parent's position

Applies to: All control types

PARENTCOLOR (BYTE): If set to 1, the COLOR property is reset to use the value of the parent control's COLOR property

Applies to: All control types but BUTTON

PARENTFONT (BYTE): If set to 1, the FONT... properties are reset to the values of the parent control's FONT... properties

Applies to: All control types

SHIFT (WORD): Current state of special keys and mouse buttons, only valid in the ONKEY event handler. This value can contain a combination of the following flags:

  • GUI_SHIFT_SHIFT (1): Shift key is down
  • GUI_SHIFT_MENU (2): Menu (Alt) key is down
  • GUI_SHIFT_CTRL (4): Ctrl key is down
  • GUI_SHIFT_MLEFT (8): Left mouse button is down
  • GUI_SHIFT_MRIGHT (16): Right mouse button is down
  • GUI_SHIFT_MMIDDLE (32): Middle mouse button is down
  • GUI_SHIFT_MDBL (64): Doublecklick

Applies to: All control types but STATIC

TAG (SIGQWORD, but only 32 bits wide): Arbitrary numeric value attached to a control

Applies to: All control types

TOP (SIGQWORD): Top position of the control relative to its parent's position

Applies to: All control types

VISIBLE (BYTE): 0: The control is not visible, 1: the control is visible

Applies to: All control types

WIDTH (LONGWORD): Overall width of the control

Applies to: All control types

WORDWRAP (BYTE): 0: The control does not automatically wrap its text at the right border, 1: the control automatically wraps its text at the right border

Applies to: BUTTON, CHECKBOX, MEMO, RADIOBUTTON, STATIC

ALLOWGRAYED (BYTE): 0: The CHECKBOX toggles between unchecked and checked state, 1: the CHECKBOX toggles between unchecked, checked and grayed state (three-state checkbox)

Applies to: CHECKBOX

AUTOSELECT (BYTE): 0: The text of the EDIT control is not automatically selected when it is focused, 1: the text is automatically selected when the EDIT control gets focused

Applies to: EDIT

AUTOSIZE (BYTE): 0: The control's height is fixed, 1: the control's height is automatically adjusted depending on the height of the text/caption's font

Applies to: EDIT, STATIC

BORDERICONS (WORD): Icons to display on the FORM's title bar. The property can be set to a combination (use the OR operator) of the following values:

  • GUI_FORMICON_SYSMENU (1): show a system menu and an icon on the left of the title bar and a close icon on the right
  • GUI_FORMICON_MINIMIZE (2): show a minimize button in the right corner of the title bar
  • GUI_FORMICON_MAXIMIZE (4): show a maximize button in the right corner of the title bar

Applies to: FORM

BORDERSTYLE (WORD): Style of the FORM's border frame. The property can be set to one of the following values:

  • GUI_BORDER_NONE (0): no border frame, FORM is not sizeable
  • GUI_BORDER_SINGLE (1): single border frame, FORM is not sizeable
  • GUI_BORDER_SIZEABLE (2): thick border frame, FORM is sizeable
  • GUI_BORDER_DIALOG (3): dialog border frame, FORM is not sizeable
  • GUI_BORDER_TOOLWIN (4): small title bar, FORM is not sizeable
  • GUI_BORDER_SIZETOOLWIN (5): small title bar, FORM is sizeable

Applies to: FORM

CANCEL (BYTE): 0: The BUTTON does not catch the ESC key, 1: the BUTTON catches the ESC key.

Applies to: BUTTON

CAPTION (TEXT): Static text of the control (see also TEXT)

Applies to: BUTTON, CHECKBOX, GROUPBOX, FORM, RADIOBUTTON, RADIOGROUP, STATIC

CHECKED (BYTE): 0: The control is in unchecked state, 1: the control is in checked state. (If a CHECKBOX is in ALLOWGRAYED (three-state) mode, use the STATE property)

Applies to: CHECKBOX, RADIOBUTTON

CLIENTHEIGHT (LONGWORD): Height of the FORM without title bar, scrollbars and border frame.

Applies to: FORM

CLIENTWIDTH (LONGWORD): Width of the FORM without scrollbars and border frame.

Applies to: FORM

COLUMNS (BYTE): Number of columns of RADIOBUTTON controls on the RADIOGROUP.

Applies to: RADIOGROUP

DEFAULT (BYTE): 0: The BUTTON does not catch the ENTER key, 1: the BUTTON catches the ENTER key.

Applies to: BUTTON

HIDESELECTION (BYTE): 0: The control's selection is visible when the control does not have the focus, 1: the selection is marked only if the control is focused.

Applies to: EDIT, MEMO

ITEMINDEX (SIGQWORD): The control's currently selected item, -1 if no item is selected

Applies to: COMBOBOX, LISTBOX, RADIOGROUP

ITEMS (TEXT): The list of all control's items, separated by NEWLINE characters. To modify single items, use the functions GUIADDITEM(), GUIDELETEITEM(), GUIGETITEM(), GUIGETITEMCOUNT(), GUISETITEM().

Applies to: COMBOBOX, LISTBOX, MEMO, RADIOGROUP

LAYOUT (WORD): Layout of the STATIC's text. The property can be set to one of the following values:

  • GUI_STATICLAYOUT_TOP (0): text is at the top of the STATIC control
  • GUI_STATICLAYOUT_CENTER (1): text is vertically centered on the STATIC control
  • GUI_STATICLAYOUT_BOTTOM (2): text is at the bottom of the STATIC control

Applies to: STATIC

MAXLENGTH (LONGWORD): Maximum number of characters the user can type, if set to 0, the max. text size depends on the operating system.

Applies to: COMBOBOX, EDIT, MEMO

MODALRESULT (WORD): If a FORM is displayed using the GUISHOWMODAL() function, it is closed if its MODALRESULT property is set to a value different from 0, and the value of this property is returned as the function result. If a BUTTON control's MODALRESULT is set to a value different from 0, this value is copied to the FORM's MODALRESULT if the button is clicked and thus the form is closed. Common values are (defined in def.mps):

  • IDOK = 1
  • IDCANCEL = 2
  • IDABORT = 3
  • IDRETRY = 4
  • IDIGNORE = 5
  • IDYES = 6
  • IDNO = 7

Applies to: BUTTON, FORM

MULTISELECT (BYTE): 0: Only one item of the LISTBOX control can be selected at a time, 1: multiple items can be selected at a time. Use the GUISELECTITEM() and GUIITEMSELECTED() functions to work with multiple selection LISTBOX controls.

Applies to: LISTBOX

PASSWORDCHAR (CHAR): If this property is set to a value different from CHAR(0), the text the user types is not visible, all characters are replaced by the value of this property in the display of the EDIT control.

Applies to: EDIT

POSITION (WORD): Initial position of the FORM control. Possible values are:

  • GUI_FORMPOS_DESIGNED (0): Position as designed
  • GUI_FORMPOS_DEFAULT (1): Position and Size defined by the operating system
  • GUI_FORMPOS_DEFAULTPOS (2): Position defined by the Operating system, size as designed
  • GUI_FORMPOS_DEFAULTSIZE (3): Size defined by the Operating system, position as designed
  • GUI_FORMPOS_SCREENCENTER (4): Center on the screen
  • GUI_FORMPOS_DESKTOPCENTER (5): Center on the desktop
  • GUI_FORMPOS_PARENTCENTER (7): Center on the parent window

Applies to: FORM

READONLY (BYTE): 0: The user can change the text of the control using the keyboard, 1: the user cannot change the control's text.

Applies to: EDIT, MEMO

SCROLLBARS (WORD): Tells the GUI engine which scrollbars the MEMO control should display. Possible values are:

  • GUI_MEMOSCROLLBAR_NONE (0): No scrollbars
  • GUI_MEMOSCROLLBAR_HORZ (1): Horizontal scrollbar
  • GUI_MEMOSCROLLBAR_VERT (2): Vertical scrollbar
  • GUI_MEMOSCROLLBAR_BOTH (3): Horizontal and vertical scrollbars

Applies to: MEMO

SELCOUNT (LONGWORD): Number of selected items in a LISTBOX control in MULTISELECT mode.

Applies to: LISTBOX

SELLENGTH (LONGWORD): Length of the control's editable text (in characters) currently selected.

Applies to: COMBOBOX, EDIT, MEMO

SELSTART (LONGWORD): Index of the first selected character of the control's editable text. If SELLENGTH is 0, the caret position is returned.

Applies to: COMBOBOX, EDIT, MEMO

SELTEXT (TEXT): The control's editable text that is currently selected. On write access, the current selection is replaced by the value.

Applies to: COMBOBOX, EDIT, MEMO

STATE (WORD): The CHECKBOX control's current state if it's in ALLOWGRAYED (three-state) mode. Possible values are:

  • GUI_CHECKBOXSTATE_UNCHECKED (0): Not checked
  • GUI_CHECKBOXSTATE_CHECKED (1): Checked
  • GUI_CHECKBOXSTATE_GRAYED (2): Grayed

Applies to: CHECKBOX

STYLE (WORD): The COMBOBOX control's style. Possible values are:

  • GUI_COMBOSTYLE_DROPDOWN (0): Drop-down list + Edit box
  • GUI_COMBOSTYLE_SIMPLE (1): Edit box + Fixed list
  • GUI_COMBOSTYLE_DROPDOWNLIST (2): Drop-down list only

Applies to: COMBOBOX

TEXT (TEXT): Text of the control that can be edited by the user using the keyboard (see also CAPTION)

Applies to: COMBOBOX, EDIT, MEMO

TRANSPARENT (BYTE): 0: Text and background of the STATIC control are drawn, 1: Only the STATIC control's text is drawn.

Applies to: STATIC

WINDOWSTATE (WORD): The FORM control's window state. Possible values are:

  • GUI_FORMSTATE_NORMAL (0): Normal showing
  • GUI_FORMSTATE_MINIMIZED (1): Minimized
  • GUI_FORMSTATE_MAXIMIZED (2): Maximized

Applies to: FORM

Event handlers

Each GUI control has various event handlers which can be linked to labels in the script. Then each time the corresponding event is fired, that script label is executed. Each event handling script block must use the RETURN command when finished. To assign a block of script code to an event, use GuiSetProperty(<ControlName>, <EventName>, <LabelName>), e.g. GuiSetProperty("FORM1.EDIT1", "ONCHANGE", "EDITCHANGEHANDLER"). Events are fired if certain actions are performed. They are briefly explained in this topic.

Event handlers common to most or all control types: ONCLICK, ONDBLCLICK, ONENTER, ONEXIT, ONKEY
Special event handlers: ONCHANGE, ONCLOSE, ONCREATE, ONDESTROY, ONHIDE, ONSELECT, ONSHOW

ONCLICK: This event is fired when the control has been clicked.

Applies to: All control types

ONDBLCLICK: This event is fired when the control has been doubleclicked.

Applies to: All control types but BUTTON, CHECKBOX, RADIOGROUP

ONENTER: This event is fired when the control is activated (i.e. gets the focus).

Applies to: All control types but STATIC

ONEXIT: This event is fired when the control is deactivated (i.e. loses the focus).

Applies to: All control types but STATIC

ONKEY: This event is fired when the control has the focus and a key has been pressed. The key being pressed can be retrieved and changed using the KEY property, the current state of the modifier keys and the mouse buttons can be retrieved using the SHIFT property.

Applies to: All control types but STATIC

ONCHANGE: This event is fired when the control's text has been changed.

Applies to: COMBOBOX, EDIT, MEMO

ONCLOSE: This event is fired when the FORM is closed (by setting the MODALRESULT property).

Applies to: FORM

ONCREATE: This event is fired when the FORM is created (by using the GUICREATE() function).

Applies to: FORM

ONDESTROY: This event is fired when the FORM is destroyed (by using the GUIDESTROY() function).

Applies to: FORM

ONHIDE: This event is fired when the FORM gets hidden (by setting the VISIBLE property to 0).

Applies to: FORM

ONSELECT: This event is fired after an item has been selected from the COMBOBOX control's drop-down list.

Applies to: COMBOBOX

ONSHOW: This event is fired when the FORM gets displayed (either by using the GUISHOWMODAL() function or by setting the VISIBLE property to 1).

Applies to: FORM


Command Actions

These are the CMD sub commands you can use with the EXTERN tiny hexer script command to execute menu actions via tiny hexer script.

Command name | Parameters | Description
CMD.BookmarkAdd | - | Add current position to bookmarks
CMD.BookmarkEdit | - | Change stored bookmarks
CMD.CompareCompareEditor | TEXT FileName | Compare the editor file to another open file
CMD.CompareCompareFile | TEXT FileName | Compare the editor file to a file on disk
CMD.CompareCompareSelEditor | TEXT FileName | Compare the editor's selection to a another open file
CMD.CompareCompareSelFile | TEXT FileName | Compare the editor's selection to a file on disk
CMD.CompareCompareSimilarity | TEXT FileName [, SIGBYTE DataType [, EXTENDED Bias [, BYTE DoCompareSelectionOnly [, BYTE DoTreatDataAsBigEndian]]]] | Compare the editor file to another open file by using a "bias" value
CMD.CompareNext | - | Navigate to the next block of differences
CMD.ComparePrevious | - | Navigate to the previous block of differences
CMD.CompareReset | - | Clear the comparison result buffer
CMD.CompareShowDiffs | BYTE DoHilight | Highlight bytes that differed in comparison
CMD.DiskFirstSector | - | Load first sector from disk
CMD.DiskGotoSectorPosition | SIGQWORD SectorNumber | Load a specific sector from disk
CMD.DiskLastSector | - | Load last sector from disk
CMD.DiskNextSector | - | Load next sector from disk
CMD.DiskOpenDrive | TEXT PartitionOrDrive [, LONGWORD AmountOfSectors [, SIGQWORD StartSector [, BYTE ReadOnly]]] | Open a hard disk, floppy or CDRom
CMD.DiskOpenFileAsDrive | TEXT ImageFileName [, LONGWORD AmountOfSectors [, SIGQWORD StartSector [, LONGWORD BytesPerSector [, BYTE ReadOnly]]]] | Open a disk image or large file (> 2 GB) in sector mode
CMD.DiskPreviousSector | - | Load previous sector from disk
CMD.DiskWriteSector | - | Write changes back to disk
CMD.EditAddToPosList | - | Add the current position to the position list
CMD.EditConvert | TEXT TranslationFrom, TEXT TranslationTo [, BYTE DoConvertSelectionOnly] | Convert data
CMD.EditCopy | - | Copy selection to clipboard
CMD.EditCut | - | Cut selection to clipboard
CMD.EditDelete | - | Delete the current selection
CMD.EditDeleteNibble | - | Delete a half byte (nibble) at the current position
CMD.EditFindNext | - | Repeat most recent find action
CMD.EditFindReplace | TEXT FindReplaceWhat, BYTE DoIgnoreCase, BYTE DoFindTextOrRegEx [, TEXT Wildcard [, TEXT Replacement, BYTE DoReplaceText, BYTE DoReplaceAll]] | Find (and replace) text or data; if DoFindTextOrRegEx=2, do a regular expression search.
CMD.EditFindStore | TEXT DataToFind, BYTE DoIgnoreCase, BYTE DoFindTextOrRegEx [, TEXT Wildcard [, BYTE DoSearchWholeDisk [, BYTE DoOverwriteCurrentList]]] | Find all occurences of a data in a document and store the results in the position list. If DoFindTextOrRegEx=2, do a regular expression search.
CMD.EditGoto | LONGWORD Position | Goto position
CMD.EditInsertNibble | - | Insert a half byte (nibble) at the current position
CMD.EditPaste | - | Paste clipboard contents
CMD.EditPasteToNew* | - | Paste clipboard contents into a new editor window
CMD.EditRedo | - | Revoke last undo
CMD.EditSelect | LONGWORD SelStart, LONGWORD SelEnd | Enter start and end position of the selection
CMD.EditSelectAll | - | Select all
CMD.EditUndo | - | Undo last modification
CMD.EditUndoClearBuffer | - | Clear the current file's Undo buffer
CMD.FileClose | [TEXT FileName] | Close the current window (or the window named FileName)
CMD.FileCloseAll | - | Close all editor windows
CMD.FileExit | - | Close
CMD.FileExport* | TEXT ExportScriptName, TEXT FileName [, BYTE DoOnlySelection, BYTE DoToClipboard [, TEXT ScriptParams...] | Export file or current selection to disk or clipboard
CMD.FileImport* | TEXT FileName, TEXT ImportScriptName [, TEXT ScriptParams...] | Import data from a file in a specific format to a new document
CMD.FileImportCurrent* | TEXT FileName, TEXT ImportScriptName [, TEXT ScriptParams...] | Import data from a file in a specific format to the current document
CMD.FileImportCurrentFromClipboard * | TEXT ImportScriptName [, TEXT ScriptParams...] | Import data from in a specific format from the clipboard to the current document
CMD.FileImportFromClipboard * | TEXT ImportScriptName [, TEXT ScriptParams...] | Import data from in a specific format from the clipboard to a new document
CMD.FileInsertFile | TEXT FileName | Insert the contents of a different file
CMD.FileInsertPartialFile | TEXT FileName, LONGWORD StartPos, LONGWORD EndPos | Insert the partial (from StartPos to EndPos) contents of a different file
CMD.FileNew | - | New file
CMD.FileNewAdvanced | LONGWORD DataSize [, BYTE FillByte [, BYTE Translation [, BYTE InsertMode | FixedFileSize [, BYTE SwapNibbles]]]] | New file with specific properties
CMD.FileOpen | TEXT FileNames | Open one or more files (multiple files must be separated by char(13) and/or char(10))
CMD.FileOpenGroup* | TEXT GroupFileName | Open a group of files
CMD.FilePasteOverFile | TEXT FileName, LONGWORD Position [, BYTE SelectionOnly] | Paste the current data/selection over an existing file at position Position
CMD.FilePrint | BYTE DoPrintAutomatically | Print data
CMD.FilePrintSetup | - | Change printer options
CMD.FileProperties* | - | Show the "File properties" window
CMD.FileReload | [BYTE DoSkipConfirmation] | Reload the current file from disk
CMD.FileReopenCleanup* | - | Remove not existing files from this menu
CMD.FileSave | - | Save file
CMD.FileSaveAs | TEXT FileName | Save file under a different name
CMD.FileSaveGroup* | TEXT GroupFileName [, BYTE DoSaveAllOpenFiles] | Save a file group. If DoSaveAllFiles is set to 1, you are not prompted for selection of the files in the group but all open files are put in the group
CMD.FileSaveSelection | TEXT FileName | Save the current selection to disk
CMD.FileStatistics* | [TEXT ExportFileName [, BYTE DoCloseDialog]] | Show file statistics and possibly export them to a RTF file
CMD.HelpAbout | - | Show the About box
CMD.HelpIndex | - | Display the help index
CMD.HelpLookForUpdates | - | Look for available updates on www.mirkes.de
CMD.HelpScriptReference | - | Show the Tiny Hexer Script reference help index
CMD.HelpVersionHistory | - | Show Tiny Hexer's version history
CMD.MacroRecordPause | BYTE DoPauseMacro | Pause/Resume macro recording
CMD.MacroRecordStart | - | Start recording a tiny hexer script macro
CMD.MacroRecordStop | TEXT TargetScriptFileName | Stop recording a tiny hexer script macro and save it to a file
CMD.OptionsCustomizeTB | - | Add or delete buttons on the tool bar
CMD.OptionsEditCustomTranslationTable * | - | Edit custom translation table
CMD.OptionsEditorSettings | - | Change current editor window's properties
CMD.OptionsGlobalSettings | - | Change global settings
CMD.OptionsLoad | TEXT FileName | Restore previously saved settings
CMD.OptionsSave | TEXT FileName | Save current settings to file
CMD.ProcessReadMemory | - | Open the "Read process memory" dialog
CMD.ProcessWriteMemory | - | Show the "Write process memory" dialog
CMD.ToolsCalculator | BYTE DoShow | Show/Hide the internal calculator
CMD.ToolsConfigure* | - | Configure the toolbox
CMD.ToolsExecuteScript | TEXT ScriptFileName [, TEXT Parameters...] | Load and execute an Tiny Hexer Script
CMD.ToolsFindEditor* | BYTE DoShow | Show/Hide the editor finder
CMD.ToolsManageADS* | - | Display the dialog for managing Alternate Data Streams
CMD.ToolsPosList | BYTE DoShow | Show/Hide the position list
CMD.ToolsScriptsRescan* | - | Rebuild up the Tools/Scripts menu entries from Tiny Hexer's scripts directory
CMD.ToolsStatusWindow* | BYTE DoShow | Show/Hide the status window tool
CMD.ToolsStructureViewer | BYTE DoShow | Show/Hide the structure viewer
CMD.ToolsValueEditor | BYTE DoShow | Show/Hide the value editor
CMD.ViewEditorOffsetAbsolute | BYTE DoShowAbsoluteOffset | Switch offset display between absolute offset addresses and sector/memory block relative addresses when editing disk sectors/memory blocks
CMD.ViewEditorOffsetDec | - | Decimal offset
CMD.ViewEditorOffsetHex | - | Hexadecimal offset
CMD.ViewEditorOffsetNone | - | No offset
CMD.ViewEditorOffsetOct | - | Octal offset
CMD.ViewNumberDec | - | Show decimal numbers
CMD.ViewNumberHex | - | Show hexadecimal numbers
CMD.ViewNumberOct | - | Show octal numbers
CMD.ViewPositionFromEOF | BYTE DoViewFromEOF | Switch on/off position display relative to the end of the file
CMD.ViewReadOnlyView | BYTE DoViewReadOnly | View files, do not allow to edit
CMD.ViewSynchronize | BYTE DoSynchronize | TEXT WindowToSynchronize [, SIGQWORD SynchronizeOffset] | Start/stop editor view synchronization
CMD.ViewToggleInsertMode | BYTE DoEnableInsertMode | Switch to Insert/Overwrite mode
CMD.ViewTranslationASCII7Bit | - | Switch to ASCII 7 bits character mode
CMD.ViewTranslationCustomTranslation | - | Switch to user defined character mode
CMD.ViewTranslationDos8Bit | - | Switch to 8 bits DOS character mode
CMD.ViewTranslationEBCDICCodepage38 | - | Switch to EBCDIC codepage 38 character mode
CMD.ViewTranslationMacintosh | - | Switch to Macintosh™ character mode
CMD.ViewTranslationUnicodeBE | BYTE DoViewUnicode | Switch unicode (big endian) on/off
CMD.ViewTranslationUnicodeLE | BYTE DoViewUnicode | Switch unicode (little endian) on/off
CMD.ViewTranslationWindows | - | Switch to Windows (i.e. native, unconverted) character mode
CMD.ViewWindowBar | BYTE DoShow | Toggle the window bar
CMD.WindowCascade | - | Cascade windows
CMD.WindowTileH | - | Tile windows horizontally
CMD.WindowTileV | - | Tile windows vertically


Plugins needed

This feature is only available if plugins are enabled.


Can be used in Plugins

Developer info: This variable or function can be read/written/executed from within Tiny Hexer plugins


MSGBOX flags

The flags parameter of the MSGBOX command/function can be a combination of the following values:

Flag | Value | Description
MB_OK | 0x00 | The message box contains one push button: OK. This is the default.
MB_OKCANCEL | 0x01 | The message box contains two push buttons: OK and Cancel.
MB_ABORTRETRYIGNORE | 0x02 | The message box contains three push buttons: Abort, Retry, and Ignore.
MB_YESNOCANCEL | 0x03 | The message box contains three push buttons: Yes, No, and Cancel.
MB_YESNO | 0x04 | The message box contains two push buttons: Yes and No.
MB_RETRYCANCEL | 0x05 | The message box contains two push buttons: Retry and Cancel.
MB_CANCELTRYCONTINUE | 0x06 | Microsoft® Windows® 2000/XP: The message box contains three push buttons: Cancel, Try Again, Continue. Use this message box type instead of MB_ABORTRETRYIGNORE.
MB_ICONHAND MB_ICONERROR MB_ICONSTOP | 0x10 | A stop-sign icon appears in the message box.
MB_ICONQUESTION | 0x20 | A question-mark icon appears in the message box.
MB_ICONEXCLAMATION MB_ICONWARNING | 0x30 | An exclamation-point icon appears in the message box.
MB_ICONASTERISK MB_ICONINFORMATION | 0x40 | An icon consisting of a lowercase letter i in a circle appears in the message box.
MB_DEFBUTTON1 | 0x00 | The first button is the default button.
MB_DEFBUTTON2 | 0x0100 | The second button is the default button.
MB_DEFBUTTON3 | 0x0200 | The third button is the default button.
MB_DEFBUTTON4 | 0x0300 | The fourth button is the default button.
MB_RIGHT | 0x00080000 | The text is right-justified.


Properties

File Properties

Properties common to all files except structure viewer browser window ('::Browser' file):
Property name | Data type | Description
Clipboard | SIGQWORD | On read the clipboard file's format is returned (0 if the file is not a clipboard file), on write a clipboard file's format is set (CF_TEXT etc.)
Position | LONGWORD | File's position pointer
Size | LONGWORD | File's size
Properties of the "structure viewer" browser window ('::Browser' file):
Property name | Data type | Description
AcceptTags | BYTE | If set to 1, you can write HTML tags to the browser window. If set to 0 (default), HTML special chars are converted so they are displayed literally (e.g. '<' is converted to '&lt;')
Height | SIGQWORD | controls the height of the browser control in the structure viewer
Left | SIGQWORD | controls the left position of the structure viewer
Raw | BYTE | This property is similar to the ACCEPTTAGS property described above. In addition to this, also the HTML header and footer are omitted if set to 1, so you will have to write a complete HTML document using the FILEWRITE functions
Top | SIGQWORD | controls the top position of the structure viewer
Visible | BYTE | If set to 1, the structure viewer is shown, if set to 0, it's hidden
Width | SIGQWORD | controls the width of the browser control in the structure viewer
Properties of (hex) editor windows ('::New', '::Editor', '::Current', '::<filename>' files) :
Property name | Data type | Description
!<propname> | TEXT/SIGQWORD | Custom properties, used to e.g. store specific data to be used in scripts. A special custom property is the !Offset (SIGQWORD) property, if this is set to a value different from 0, the "virtual offset" is displayed in the offset pane of the editor window. If <propname> is omitted, a list of all custom properties is returned
AbsolutePosition | SIGQWORD | If a disk/partition is edited, this is the absolute position of the cursor on the whole disk/partition
AbsoluteSize | SIGQWORD | If a disk/partition is edited, this is the size of the whole disk/partition, not the size of the part being edited (readonly)
BackupExtension | TEXT | Extension of the backup filename (readonly)
BytesPerBlock | BYTE | Number of bytes per block displayed by the editor
BytesPerColumn | BYTE | Number of bytes per column displayed by the editor
BytesPerRow | BYTE | Number of bytes per row displayed by the editor
CharacterMode | BYTE | Character mode of the editor
ChangeVersion | SIGQWORD | How many times have the editor's contents be changed (can be used to check whether the data has been changed during script calls etc.) (readonly)
Col | LONGWORD | Editor's current column
Colors.Background | LONGWORD | Editor's background color (blue/green/red: 0xff0000 = blue)
Colors.ChangedBackground | LONGWORD | Editor's background color of modified data (Overtype mode only)
Colors.ChangedText | LONGWORD | Editor's text color of modified data (Overtype mode only)
Colors.CurrentOffset | LONGWORD | Editor's text color of the current line (Offset pane)
Colors.CurrentOffsetBackground | LONGWORD | Editor's background color of the current line (Offset pane)
Colors.CursorFrame | LONGWORD | Editor's color of the cursor frame
Colors.EvenColumn | LONGWORD | Editor's text color of data in even columns (Hex pane)
Colors.OddColumn | LONGWORD | Editor's text color of data in odd columns (Hex pane)
Colors.Offset | LONGWORD | Editor's text color ine the offset pane
Colors.OffsetBackGround | LONGWORD | Editor's background color ine the offset pane
CurrentValue | SIGQWORD | Value of the byte at the current cursor position, -1 if the editor has no data (readonly)
FileName | TEXT | Name of the file loaded in the editor (readonly)
FillByte | BYTE | This data is used to fill newly allocated memory when growing a data file
FixedSize | BYTE | 1 if the filesize is fixed (e.g. when editing disk sectors or memory blocks), 0 otherwise
Font.Color | LONGWORD | Editor's text color
Font.Name | TEXT | Editor's text font name
Font.Size | LONGWORD | Editor's text font size
HasFile | BYTE | 1 if the data in the editor has been loaded from a file, 0 otherwise (readonly)
GotoEOF | BYTE | if set to 1, set the cursor to the highest possible position, i.e. seek beyond the actual file data if InsertMode is set to 1 (writeonly)
InCharField | BYTE | 1 if the cursor is located in the character pane, 0 if located in the hex pane
InsertMode | BYTE | 1 if the caret is in INS (insert at cursor) mode, 0 if in OVW (overwrite at cursor) mode
Modified | BYTE | 1 if the data in the editor has been modified, 0 otherwise
PrintFont.Color | LONGWORD | Text color when printing
PrintFont.Name | TEXT | Text font name when printing
PrintFont.Size | LONGWORD | Text font size when printing
PrintOptions.MarginBottom | LONGWORD | Bottom margin when printing (millimeters)
PrintOptions.MarginLeft | LONGWORD | Left margin when printing
PrintOptions.MarginRight | LONGWORD | Right margin when printing
PrintOptions.MarginTop | LONGWORD | Top margin when printing
PrintOptions.PageFooter | TEXT | Page footer text
PrintOptions.PageHeader | TEXT | Page header Text
ReadOnlyFile | BYTE | 1 if the file has been opened readonly, 0 otherwise
Row | LONGWORD | Editor's current row
SelCount | LONGWORD | Number of bytes currently selected
SelStart | LONGWORD | Index of first byte of the currently selected data
SendCharacters | TEXT | Send the given characters to the hex editor as if they were typed manually (writeonly)


Tiny Hexer Script: Graphical user interfaces

Tiny Hexer Script: Graphical user interfaces (obsolete)

Note: As of version 1.6.0.2, HTML forms have been superseded by GUI functions in Tiny Hexer Script

You can use graphical user interfaces in Tiny Hexer Script via HTML forms in the structure viewer.

If you want to use custom dialogs in Tiny Hexer Scripts (e.g. to let the user change script settings), you can display and evaluate HTML Forms in the structure viewer. The structure viewer usually escapes all html special characters (like < and >) so they are displayed as characters in the browser window. To write HTML tags into the browser window, use the ACCEPTTAGS and RAW properties of the special browser file. Then you can write HTML code into the browser window of the structure viewer (which is an instance of Internet Explorer).

In this HTML code you can use hyperlinks to let the script be executed at a specific LABEL using the syntax <a href="@labelname">.... When the user clicks such a link, the script is executed at the label labelname.

You can also use HTML forms to execute the script at a label labelname using the syntax <form method="post" action="https://@labelname">... (method must be "post" to allow Tiny Hexer to retrieve the form's parameters, the "https://" prefix in the action argument is optional, but without this the Internet Explorer control might show a warning about "Sending unencrypted data over the Internet" before the soubroutine is called). The form's parameters are available in the called script subroutine on the stack, use the POP command to retrieve them.

If a label in Tiny Hexer Script is called via a HTML form in the structure viewer, the form's parameters are stored on the stack in a specific layout: The first value on the stack is the name of the first parameter, the second value is the data of the first parameter, the third value is the name of the second parameter, the fourth value is the data of the second parameter and so on. Use the ARGC special variable to retrieve the amount of values on the stack. All values on the stack are of type TEXT.

You can avoid the fixed format of HTML forms in the structure viewer by setting the RAW property to 1 and writing a complete HTML file to the browser window (including <html>, <head> and <body> structures). See the script "Extract strings.mps" in Tiny Hexer's scripts subdirectory for a more sophisticated example.

An example which asks for the forename, the surename and the location of the user:
= all scripts to be executed in the structure viewer must be marked with this option
OPTION TARGET, STRUCTUREVIEWER

= open the browser window and write the form
VAR browser FILE
browser = FILEOPEN('::browser', 'c')

= do not escape html characters to allow html tags
FILESETPROP browser, 'accepttags', 1

= use a HERE document to write the form
FILEWRITE browser <<
<form method="post" action="https://@showformparams">
Enter your forename: <input name="forename" />
Enter your surname:  <input name="surname" />
Enter your location: <input name="location" />
<hr>
<button type="submit">Continue</button>
</form>

>>

FILECLOSE browser
END

= now, if the user clicks the "Continue" button, the label
= "showformparams" is called

@@showformparams

VAR fore TEXT sur TEXT loc TEXT name TEXT num SIGQWORD

= retrieve the form's parameters
num = ARGC := are there parameters on the stack?
WHILE num > 0
  POP name
  IF (name == 'forename')
    POP fore
  ELSE
    IF (name == 'surname')
      POP sur
    ELSE
      IF (name == 'location')
        POP loc
      ELSE
        ERROR ("Unknown parameter: "+name)
      ENDIF
    ENDIF
  ENDIF
  INC num,-2
ENDWHILE

= welcome the user
MSGBOX ("Hello "+fore+" "+sur+" from "+loc)

This script's output will look like this:


Manage infos

Using this dialog you can select the items that are displayed on the Status window.

  1. Available infos: This list contains all available items that can be added to the "Current infos" list (and thus to the status window). By doubleclicking an item (or using the "Add button" command (3)), this item is copied from this list to the "Current infos" list; it is inserted at the current position. An item can be added to the "Current infos" multiple times, so you can display the same kind of information in different data and number formats.
  2. Current infos: This list displays all commands that are shown on the status window. By doubleclicking an item (or using the "Remove button" command (4)), an item can be removed from this list.
  3. Add button: Copy the selected item from the left list to the right list to show this item on the status window
  4. Remove button: Remove the seleted item from the right list so it is removed from the status window
  5. Move up: Move the selected item in the right list one position up
  6. Move down: Move the selected item in the right list one position down
  7. Load: Load a previously saved list of current items from a file
  8. Save: Save the current items list to a file
  9. Reset: Reset the "Current infos" list to factory defaults
  10. Help: Show this help topic
  11. OK: Accept the changes and rebuild the status window list
  12. Cancel: Close the dialog without accepting the changes


Type inspector*

The former Type Inspector tool has been superseded by the Status window.


Read process memory: No data could be read from the process

None of the process' memory blocks could be accessed. On Windows NT/2000/XP you might need administrative privileges to get access to some processes. Even as an administrator, some (system) processes might be completely unaccessible from other processes.
See also: Read process memory dialog.


Read process memory: Size of data to search for must be a multiple of Bytes per unit

You cannot search in odd-sized memory blocks if the unicode box is checked. Please uncheck that box.
See also: Read process memory dialog.


Read process memory: Data not found

The data you searched for could not be found in the process's memory. You can search again by clicking the find button after selecting the first memory block in the memory block list. You might additionally toggle the unicode checkbox if you are searching for text.
See also: Read process memory dialog.


Read process memory: The data could not be found in the current memory block

The data you searched for could not be found in the process's selected memory block.

You have the following choices:
  • Yes: Search in the memory block following the currently selected block
  • No: Stop searching
  • Yes to all: Search in all memory blocks following the selected one and/or in all processess following the selected one (depends on the answer to the following message box question)
See also: Read process memory dialog.


Read process memory: Search in all following processes in the list

Here you can choose whether to search in all following processes in the process list or just all following memory blocks of the currently selected process.

You have the following choices:
  • Yes: Search in all memory blocks following the selected one and in all processess following the selected one
  • No: Search in all memory blocks following the selected one
  • Cancel: Stop searching
See also: Read process memory dialog.


Options: This hotkey is already used

The menu shortcut you entered is already used by another command. Assigning a shortcut to more than one menu command leads to unpredictable shortcut handling.

Please choose a different shortcut.
See also: Options dialog.


Save changes

The file to be closed has been modified but not yet saved.

You have the following choices:
  • Yes: Save the file to disk
  • No: Do not save the file (so modifications are lost)
  • Cancel: Do not close the file


No differences found, but the file is larger than the data to compare

Though the first sizeof(editor file) bytes of the disk file's data match the editor data, the disk file is larger than the editor file, so they do not contain the same data.
See also: File comparison.


No differences found, but the file is smaller than the data to compare

Though the first sizeof(disk file) bytes of the editor file's data match the disk file data, the disk file is smaller than the editor file, so they do not contain the same data.
See also: File comparison.


The file is smaller than the data to compare

Editor and disk file contain different data and the file on disk is smaller than the compared editor data.
See also: File comparison.


The file is larger than the data to compare

Editor and disk file contain different data and the file on disk is larger than the compared editor data.
See also: File comparison.


No more blocks of differences

The cursor is already located in the last consecutive block of different bytes.
See also: File comparison.


No previous block of differences

The cursor is already located in the first consecutive block of different bytes.
See also: File comparison.


File is already open. Open it again as unnamed file

The file you chose to open in Tiny Hexer is already opened. A file can only be opened once at a time in Tiny Hexer.

You have the following choices:
  • Yes: Open the file's data in a new editor window but detach it from the original disk file.
  • No: Do not open the file again but activate the already opened file.
  • Cancel: Stop opening files.


Do you really want to write to disk?

You are about to overwrite data on a disk or partition. The operating system likely may have changed the data on disk while you modified it in Tiny Hexer. So writing back the data to disk may lead to an inconsistent file system, that is all data on that partition might get lost.

When you try to overwrite a drive's partition table with incorrect data, all data on that disk is lost!

You have the following choices:
  • OK: Overwrite the data on disk with the editor's data.
  • Cancel: Do not write the editor's data back to disk.
See also: File/Disk menu.


Size of data to search for must be a multiple of Bytes per unit

This error message is displayed when you try to search for odd-sized data when the editor is in unicode mode.


Size of replacement data must be a multiple of Bytes per unit

This error message is displayed when you try to replace with odd-sized data if the editor is in unicode mode.


Find: The data has not been found in the currently edited sector(s)

The data you searched for could not be found in the disk sector(s) loaded into to editor.

You have the following choices:
  • Yes: Repeat the search in the following range of sectors
  • No: Stop searching
  • Yes to all: Repeat the search in all following sectors
Hint: To search for data crossing sector boundaries, you should at least load two sectors at once into the editor. If more than one sector is edited at a time, choosing 'Yes' or 'Yes To All' forces Tiny Hexer to load the last currently edited sector again (e.g. sectors 0-1 (two sectors at once), then 1-2, 2-3 and so on).
See also: Open drive/partition dialog.


Overwrite the existing position list's data

The position list already contains entries.

You have the following choices:
  • Yes: Clear the position list before adding entries to it.
  • No: Merge the existing entries with the entries found.
  • Cancel: Stop search.


Search whole disk/partition

You are searching for all occurences of data on a disk or partition.

You have the following choices:
  • Yes: Search on the whole disk or partition.
  • No: Only search in the data currently loaded into the editor.
  • Cancel: Stop search.


Do you really want to lose all changes and reload

You have requested to discard all changes in the document that are not yet saved to disk and return the document to the original contents of the associated file.

You have the following choices:
  • Yes: Discard the changes and reload the file from disk
  • No: Do not reload the file from disk


Do you really want to clear the undo buffer for the current file

When clearing the undo buffer of a file, all previously recorded modifications become permanent, so the undo command is disabled until the file is modified again.

You have the following choices:
  • Yes: Clear the undo buffer for the current file
  • No: Do not clear the undo buffer


The amount of data to be converted is odd. Continue anyway

The data you want to convert has a unit size that does not fit into the selected data range (e.g. unicode has a unit size of two bytes, LONGWORD has a unit size of four bytes).

You have the following choices:
  • Yes: Let the data be converted. Some data at the end will remain unconverted
  • No: Do not convert the data


Do you want to write changes back to disk?

You are about to locate another sector on the disk while having unsaved changes on the currently edited sectors. Writing back changes to disk will lead to data on a disk or partition being overwritten. The operating system likely may have changed the data on disk while you modified it in Tiny Hexer. So writing back the data to disk may lead to an inconsistent file system, that is all data on that partition might get lost.

When you try to overwrite a drive's partition table with incorrect data, all data on that disk is lost!

You have the following choices:
  • Yes: Overwrite the data on disk with the editor's data.
  • No: Do not write the editor's data back to disk before locating a different sector.
  • Cancel: Do not write the editor's data back to disk and don't change the current sector.
See also: File/Disk menu.


File is not a structure viewer script

The script you want to execute in the structure viewer seems not be designed for it. Structure viewer scripts are usually located in the scripts\Structure Viewer directory.

However, if you still want to open this script in the structure viewer, please make sure the script contains the line OPTION TARGET, STRUCTUREVIEWER.


Overwrite the existing position list's data

The position list already contains entries.

You have the following choices:
  • Yes: Clear the position list before loading entries from file.
  • No: Merge the existing entries with the entries in the file.
  • Cancel: Stop loading the file's entries.


The file doesn't seem to be a Tiny Hexer configuration file. Load it anyway?

The configuration file to be loaded has either been created by an old version of Tiny Hexer or by another application.

You have the following choices:
  • Yes: Load the settings from this file.
  • No: Do not load the settings from this file.